From 12136751f3b70838a5373068ad0afe87d31d5078 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 26 Aug 2018 19:36:20 +0200 Subject: [PATCH] Implement other scripts --- README.md | 66 ++----- check_process | 27 ++- conf/systemd.service | 2 +- manifest.json | 5 +- scripts/_common.sh | 433 ------------------------------------------- scripts/backup | 28 +-- scripts/change_url | 19 -- scripts/install | 6 + scripts/restore | 49 +---- scripts/upgrade | 62 ++----- 10 files changed, 59 insertions(+), 638 deletions(-) diff --git a/README.md b/README.md index 4216ec8..d3ad7e0 100644 --- a/README.md +++ b/README.md @@ -1,71 +1,27 @@ -# APP for YunoHost +# YunoRunner for YunoHost -[![Integration level](https://dash.yunohost.org/integration/APP.svg)](https://dash.yunohost.org/appci/app/APP) -[![Install APP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=APP) +[![Integration level](https://dash.yunohost.org/integration/APP.svg)](https://dash.yunohost.org/appci/app/yunorunner) +[![Install YunoRunner with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=yunorunner) -*[Lire ce readme en français.](./README_fr.md)* - -> *This package allow you to install APP quickly and simply on a YunoHost server. +> *This package allow you to install YunoRunner quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview -Small description... +YunoRunner is our own CI runner for YunoHost Apps -**Shipped version:** version - -## Screenshots - -![](screenshot.png) - -## Demo - -No demo available. - -## Configuration - -How to configure - -## Documentation - - * Official documentation: http://online_doc - * YunoHost documentation: There no other documentations, feel free to contribute. - -## YunoHost specific features - -#### Multi-users support - -Supported, with LDAP and SSO. +**Shipped version:** Work in progress... #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)/) -* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)%20(%7EARM%7E)/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/jenkins/job/leed%20(Community)/badge/icon)](https://ci-stretch.nohost.me/jenkins/job/leed%20(Community)/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/yunorunner%20(Community)/) +* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/APP%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/yunorunner%20(Community)%20(%7EARM%7E)/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/jenkins/job/leed%20(Community)/badge/icon)](https://ci-stretch.nohost.me/jenkins/job/yunorunner%20(Community)/) ## Limitations -* Any limitations... - -## Additionnal informations - -* Other informations +* You need to install [CI_package_check](https://github.com/YunoHost/CI_package_check) before YunoRunner and modify the systemd script to add the path of the script analyseCI.sh. ## Links - * Report a bug: https://github.com/YunoHost-Apps/APP_ynh/issues - * APP website: http://APP.org/ + * Report a bug: https://github.com/YunoHost-Apps/yunorunner_ynh/issues * YunoHost website: https://yunohost.org/ - ---- - -Developers infos ----------------- - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/APP_ynh/tree/testing). - -To try the testing branch, please proceed like that. -``` -sudo yunohost app install https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose -or -sudo yunohost app upgrade APP -u https://github.com/YunoHost-Apps/APP_ynh/tree/testing --verbose -``` diff --git a/check_process b/check_process index f9d9507..a8189a7 100644 --- a/check_process +++ b/check_process @@ -1,32 +1,29 @@ ;; Test complet + ; pre-install + git clone https://github.com/YunoHost/CI_package_check /home ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - admin="john" (USER) - language="fr" - is_public=1 (PUBLIC|public=1|private=0) - password="pass" - port="666" (PORT) ; Checks pkg_linter=1 setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b +# upgrade=1 from_commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b backup_restore=1 - multi_instance=1 + multi_instance=0 incorrect_path=1 - port_already_use=1 + port_already_use=0 change_url=0 ;;; Levels Level 1=auto Level 2=auto Level 3=auto -# Level 4: - Level 4=0 +# Level 4: No users management + Level 4=na Level 5=auto Level 6=auto Level 7=auto @@ -36,7 +33,7 @@ ;;; Options Email= Notification=down -;;; Upgrade options - ; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b - name=20 Jan 2017 b86b9d09ed97bf04b7e1afad72376d8d695b418b - manifest_arg=domain=DOMAIN&admin=USER&path=PATH&language=en&is_public=Yes&abiword=0& +#;;; Upgrade options +# ; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b +# name=20 Jan 2017 b86b9d09ed97bf04b7e1afad72376d8d695b418b +# manifest_arg=domain=DOMAIN&admin=USER&path=PATH&language=en&is_public=Yes&abiword=0& diff --git a/conf/systemd.service b/conf/systemd.service index b4138ba..f7e76b2 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ -ExecStart=__FINALPATH__/ve3/bin/python ./run.py __PCHECK_PATH__/analyseCI.sh >> /var/log/__APP__/__APP__.log 2&>1 +ExecStart=__FINALPATH__/ve3/bin/python ./run.py /home/CI_package_check/analyseCI.sh >> /var/log/__APP__/__APP__.log 2&>1 [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 9c5fbf2..7e6271c 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,7 @@ "id": "yunorunner", "packaging_format": 1, "description": { - "en": "Description", - "fr": "Description" + "en": "CI runner for YunoHost" }, "version": "1.0~ynh1", "url": "https://github.com/YunoHost/yunorunner", @@ -16,7 +15,7 @@ "requirements": { "yunohost": ">= 3.1.0" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ], diff --git a/scripts/_common.sh b/scripts/_common.sh index 2b85245..61f13bf 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,35 +1,5 @@ #!/bin/bash -#================================================= -# BACKUP -#================================================= - -HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain - human=$(numfmt --to=iec --from-unit=1K $1) - echo $human -} - -CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant - file_to_analyse=$1 - backup_size=$(du --summarize "$file_to_analyse" | cut -f1) - free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d) - - if [ $free_space -le $backup_size ] - then - ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse." - ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)" - ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)" - fi -} - -#================================================= -# PACKAGE CHECK BYPASSING... -#================================================= - -IS_PACKAGE_CHECK () { - return $(env | grep -c container=lxc) -} - #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -227,316 +197,6 @@ ynh_handle_getopts_args () { #================================================= -# Start or restart a service and follow its booting -# -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: -m, --line_to_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: -l, --app_log= - Log file - The log file to watch; specify "systemd" to read systemd journal for specified service -# /var/log/$app/$app.log will be used if no other log is defined. -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -# | arg: -n, --service_name= - Service name - -ynh_check_starting () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=line_to_match= [l]=app_log= [t]=timeout= [n]=service_name= ) - local line_to_match - local app_log - local timeout - local service_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - local app_log="${app_log:-/var/log/$service_name/$service_name.log}" - local timeout=${timeout:-300} - local service_name="${service_name:-$app}" - - echo "Starting of $service_name" >&2 - systemctl stop $service_name - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$app_log" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$app_log" > "$templog" & - fi - # Get the PID of the last command - local pid_tail=$! - systemctl start $service_name - - local i=0 - for i in `seq 1 $timeout` - do - # Read the log until the sentence is found, which means the app finished starting. Or run until the timeout. - if grep --quiet "$line_to_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully start before the timeout." >&2 - fi - - echo "" - ynh_clean_check_starting -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} - -#================================================= - -ynh_print_log () { - echo "${1}" -} - -# Print an info on stdout -# -# usage: ynh_print_info "Text to print" -# | arg: text - The text to print -ynh_print_info () { - ynh_print_log "[INFO] ${1}" -} - -# Print a warning on stderr -# -# usage: ynh_print_warn "Text to print" -# | arg: text - The text to print -ynh_print_warn () { - ynh_print_log "[WARN] ${1}" >&2 -} - -# Print a error on stderr -# -# usage: ynh_print_err "Text to print" -# | arg: text - The text to print -ynh_print_err () { - ynh_print_log "[ERR] ${1}" >&2 -} - -# Execute a command and print the result as an error -# -# usage: ynh_exec_err command to execute -# usage: ynh_exec_err "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_err () { - ynh_print_err "$(eval $@)" -} - -# Execute a command and print the result as a warning -# -# usage: ynh_exec_warn command to execute -# usage: ynh_exec_warn "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_warn () { - ynh_print_warn "$(eval $@)" -} - -# Execute a command and force the result to be printed on stdout -# -# usage: ynh_exec_warn_less command to execute -# usage: ynh_exec_warn_less "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_warn_less () { - eval $@ 2>&1 -} - -# Execute a command and redirect stdout in /dev/null -# -# usage: ynh_exec_quiet command to execute -# usage: ynh_exec_quiet "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_quiet () { - eval $@ > /dev/null -} - -# Execute a command and redirect stdout and stderr in /dev/null -# -# usage: ynh_exec_fully_quiet command to execute -# usage: ynh_exec_fully_quiet "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_fully_quiet () { - eval $@ > /dev/null 2>&1 -} - -# Remove any logs for all the following commands. -# -# usage: ynh_print_OFF -# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging. -ynh_print_OFF () { - set +x -} - -# Restore the logging after ynh_print_OFF -# -# usage: ynh_print_ON -ynh_print_ON () { - set -x - # Print an echo only for the log, to be able to know that ynh_print_ON has been called. - echo ynh_print_ON > /dev/null -} - -#================================================= - -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.0" - local checksum="4852c8607db820ad51f348da0dcf0c88" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Add a directory in yunohost.multimedia -# This "directory" will be a symbolic link to a existing directory. -# -# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" -ynh_multimedia_addfolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" -} - -# Move a directory in yunohost.multimedia, and replace by a symbolic link -# -# usage: ynh_multimedia_movefolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# It will be moved to "Destination directory" -# A symbolic link will replace it. -# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia" -ynh_multimedia_movefolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir" -} - -# Allow an user to have an write authorisation in multimedia directories -# -# usage: ynh_multimedia_addaccess user_name -# -# | arg: -u, --user_name= - The name of the user which gain this access. -ynh_multimedia_addaccess () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=user_name=) - local user_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - groupadd -f multimedia - usermod -a -G multimedia $user_name -} - -#================================================= - -# Create a dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]] -# | arg: log_file - Log file to be checked by fail2ban -# | arg: failregex - Failregex to be looked for by fail2ban -# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3 -# | arg: ports - Ports blocked for a banned IP address - default: http,https -ynh_add_fail2ban_config () { - # Process parameters - logpath=$1 - failregex=$2 - max_retry=${3:-3} - ports=${4:-http,https} - - test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." - test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing." - - finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf" - finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1 - ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1 - - sudo tee $finalfail2banjailconf <&2 - echo "WARNING${fail2ban_error#*WARNING}" >&2 - fi -} - -# Remove the dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_remove_fail2ban_config -ynh_remove_fail2ban_config () { - ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" - ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" - systemctl restart fail2ban -} - -#================================================= - # Read the value of a key in a ynh manifest file # # usage: ynh_read_manifest manifest key @@ -628,75 +288,6 @@ ynh_check_app_version_changed () { #================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: -m --app_message= - The message to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= ) - local app_message - local recipients - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - local app_message="${app_message:-...No specific information...}" - local recipients="${recipients:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$app_message - ---- -Automatic diagnosis data from YunoHost - -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} - -#================================================= - # Reload (or other actions) a service and print a log in case of failure. # # usage: ynh_system_reload service_name [action] @@ -717,30 +308,6 @@ ynh_system_reload () { #================================================= -ynh_debian_release () { - lsb_release --codename --short -} - -is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi -} - -is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi -} - -#================================================= - # Delete a file checksum from the app settings # # $app should be defined when calling this helper diff --git a/scripts/backup b/scripts/backup index c69eb90..207770a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,8 +24,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) -db_pwd=$(ynh_app_setting_get $app mysqlpwd) #================================================= # STANDARD BACKUP STEPS @@ -33,7 +31,6 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) # BACKUP OF THE MAIN DIR OF THE APP #================================================= -CHECK_SIZE "$final_path" ynh_backup "$final_path" #================================================= @@ -42,27 +39,6 @@ ynh_backup "$final_path" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP OF THE PHP-FPM CONFIGURATION -#================================================= - -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" -ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" - -#================================================= -# BACKUP OF THE SQL BDD -#================================================= - -ynh_mysql_dump_db "$db_name" > db.sql -CHECK_SIZE "db.sql" - -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= - -ynh_backup "/etc/fail2ban/jail.d/$app.conf" -ynh_backup "/etc/fail2ban/filter.d/$app.conf" - #================================================= # SPECIFIC BACKUP #================================================= @@ -78,7 +54,7 @@ ynh_backup "/etc/logrotate.d/$app" ynh_backup "/etc/systemd/system/$app.service" #================================================= -# BACKUP OF THE CRON FILE +# BACKUP OF PYTHONZ #================================================= -ynh_backup "/etc/cron.d/$app" +ynh_backup "$HOME/.pythonz" diff --git a/scripts/change_url b/scripts/change_url index 9030015..bf73d54 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,10 +36,6 @@ test -n "$new_path" || new_path="/" new_path=$(ynh_normalize_url_path $new_path) old_path=$(ynh_normalize_url_path $old_path) -echo "old_path=$old_path" >&2 ## DEBUG -echo "new_path=$new_path" >&2 ## DEBUG -echo "-" >&2 ## DEBUG - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= @@ -107,27 +103,12 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# UPDATE SSOWAT -#================================================= - -sudo cat "/etc/yunohost/apps/$app/settings.yml" >&2 ## DEBUG -echo "-" >&2 ## DEBUG - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= -cat "$nginx_conf_path" >&2 ## DEBUG - ynh_system_reload --service_name=nginx #================================================= diff --git a/scripts/install b/scripts/install index 13fe447..7265666 100644 --- a/scripts/install +++ b/scripts/install @@ -153,3 +153,9 @@ ynh_app_setting_set $app skipped_uris "/" #================================================= ynh_system_reload --service_name=nginx + +#================================================= +# START YUNORUNNER +#================================================= + +ynh_system_reload --service_name=yunorunner --action=start diff --git a/scripts/restore b/scripts/restore index 066925a..1965428 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,8 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Load common variables for all scripts. -source ../settings/scripts/_variables #================================================= # MANAGE SCRIPT FAILURE @@ -27,7 +25,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -58,14 +55,6 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "$final_path" -#================================================= -# RESTORE OF THE SQL BDD -#================================================= - -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql - #================================================= # RECREATE OF THE DEDICATED USER #================================================= @@ -79,28 +68,13 @@ ynh_system_user_create $app # Recreate the dedicated user, if not exist # Les fichiers appartiennent à root chown -R root: $final_path -#================================================= -# RESTORE OF THE PHP-FPM CONFIGURATION -#================================================= - -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" -ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" - -#================================================= -# RESTORE FAIL2BAN CONFIGURATION -#================================================= - -ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" -ynh_system_reload --service_name=fail2ban --action=restart - #================================================= # SPECIFIC RESTORE #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_install_app_dependencies $app_depencencies +ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev #================================================= # ENABLE SERVICE IN ADMIN PANEL @@ -117,10 +91,10 @@ ynh_restore_file "/etc/systemd/system/$app.service" systemctl enable $app.service #================================================= -# RESTORE OF THE CRON FILE +# RESTORE OF PYTHONZ #================================================= -ynh_restore_file "/etc/cron.d/$app" +ynh_restore_file "$HOME/.pythonz" #================================================= # BACKUP OF THE LOGROTATE CONFIGURATION @@ -131,22 +105,19 @@ ynh_restore_file "/etc/logrotate.d/$app" #================================================= # GENERIC FINALISATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= -ynh_system_reload --service_name=php5-fpm ynh_system_reload --service_name=nginx +#================================================= +# START YUNORUNNER +#================================================= + +ynh_system_reload --service_name=yunorunner --action=start + #================================================= # DEACTIVE MAINTENANCE MODE #================================================= ynh_maintenance_mode_OFF - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/modele_ynh" - -ynh_send_readme_to_admin --app_message="$message" --recipients="$admin root" diff --git a/scripts/upgrade b/scripts/upgrade index 95bee95..14afc69 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,8 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -# Load common variables for all scripts. -source _variables #================================================= # LOAD SETTINGS @@ -19,11 +17,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) -is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) -port=$(ynh_app_setting_get $app port) -db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK VERSION @@ -35,19 +29,6 @@ upgrade_type=$(ynh_check_app_version_changed) # ENSURE DOWNWARD COMPATIBILITY #================================================= -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 - is_public=0 -fi - -if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting - db_name=$(ynh_sanitize_dbid $app) - ynh_app_setting_set $app db_name $db_name -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -84,6 +65,12 @@ then ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path fi +#================================================= +# UPGRADE DEPENDENCIES +#================================================= + +ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev + #================================================= # NGINX CONFIGURATION #================================================= @@ -96,22 +83,8 @@ ynh_add_nginx_config ynh_system_user_create $app # Create the dedicated user, if not exist -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure. - #================================================= # SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - -# Copie ou modification d'un fichier de config -ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" # Créé un backup du fichier de config si il a été modifié. -ynh_store_file_checksum "$final_path/CONFIG_FILE" # Réenregistre la somme de contrôle du fichier de config - #================================================= # SETUP LOGROTATE #================================================= @@ -127,11 +100,6 @@ ynh_add_systemd_config #================================================= # GENERIC FINALISATION #================================================= -# UPGRADE FAIL2BAN -#================================================= - -ynh_add_fail2ban_config "/var/log/nginx/${domain}-error.log" "PHP message: Leed: wrong login for .* client: " 5 - #================================================= # SECURING FILES AND DIRECTORIES #================================================= @@ -143,15 +111,8 @@ chown -R root: $final_path # SETUP SSOWAT #================================================= -if [ $is_public -eq 0 ] -then # Retire l'accès public - ynh_app_setting_delete $app skipped_uris -fi -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_app_setting_set $app skipped_uris "/" -fi +# Make app public +ynh_app_setting_set $app skipped_uris "/" #================================================= # RELOAD NGINX @@ -159,6 +120,13 @@ fi ynh_system_reload --service_name=nginx +#================================================= +# RESTART YUNORUNNER +#================================================= + +ynh_system_reload --service_name=yunorunner --action=restart + + #================================================= # DEACTIVE MAINTENANCE MODE #=================================================