From b8ec4d75958be0935e31d3eef547669fe8cd9e6d Mon Sep 17 00:00:00 2001 From: Krakinou Date: Fri, 21 Dec 2018 19:58:23 +0100 Subject: [PATCH] Update with check_process & package_linter --- .project | 11 +++++++++++ check_process | 38 ++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .project create mode 100644 check_process diff --git a/.project b/.project new file mode 100644 index 0000000..24d3b92 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + poubelle_ynh + + + + + + + + diff --git a/check_process b/check_process new file mode 100644 index 0000000..fd21e38 --- /dev/null +++ b/check_process @@ -0,0 +1,38 @@ +;; Complete Test +# Comment ignored + ; Manifest + domain="domain.tld" (DOMAIN) + path="/poubelle" (PATH) + admin="john" (USER) + is_public=0 (PUBLIC|public=1|private=0) + password="password" + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=0 + incorrect_path=1 + port_already_use=0 (XXXX) + change_url=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=0 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 +;;; Options +Email= +Notification=none +;;; Upgrade options +# ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 + name=Name of this previous version + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=0& \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 65cd665..5c7e84e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,19 +7,46 @@ #================================================= source _common.sh source /usr/share/yunohost/helpers + + #================================================= # LOAD SETTINGS #================================================= 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) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + + +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) + + +#================================================= #check for matlink's version +#================================================= + cat /etc/yunohost/apps/$app/status.json | grep "matlink" if [[ $?==0 ]]; then #add missing info in settings @@ -61,6 +88,11 @@ if [[ $?==0 ]]; then fi + +#================================================= +# NGINX CONFIGURATION +#================================================= + #change nginx.conf as per https://forum.yunohost.org/t/need-help-on-nginx-conf-cannot-access-resources/6342 ynh_replace_string "alias $finalpath/www/ ;" "alias $finalpath/ ;" /etc/yunohost/$domain.d/$app.conf ynh_replace_string "index index.php;" "index www/ndex.php;" /etc/yunohost/$domain.d/$app.conf @@ -68,6 +100,8 @@ ynh_replace_string "index index.php;" "index www/ndex.php;" /etc/yunohost/$domai #correct template name in index.php ynh_replace_string "Template-exemple" "$domain" $final_path/www/index.php + + #mysqlpwd setting was implemented in ynh2 - check if saved and if not implement db_pass=$(ynh_app_setting_get $app mysqlpwd) if [ -z $db_pass]; then @@ -106,7 +140,9 @@ chown -R www-data:www-data $final_path #sudo echo "$cronline" | sudo tee -a /etc/cron.d/emailpoubelle #sudo chmod 644 /etc/cron.d/emailpoubelle -# Restart services +#================================================= +# RELOAD SERVICES +#================================================= systemctl restart php7.0-fpm systemctl reload nginx systemctl reload postfix