From f1dd9193ca5407866c2d3a39bd3384734e4bbe77 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 5 Aug 2021 00:51:27 +0200 Subject: [PATCH] Apply last example_ynh --- check_process | 3 ++- manifest.json | 4 ++-- scripts/_common.sh | 2 +- scripts/backup | 2 +- scripts/change_url | 5 +++-- scripts/install | 6 +++--- scripts/restore | 12 ++++++------ scripts/upgrade | 38 +++++++++++++++++++------------------- 8 files changed, 37 insertions(+), 35 deletions(-) diff --git a/check_process b/check_process index 1d94513..98d6a69 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,7 @@ admin="john" language="fr" is_public=1 - password="pass" + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -18,6 +18,7 @@ upgrade=1 from_commit=f618522e430dfcb63e1a5843535cf0da165025f3 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= diff --git a/manifest.json b/manifest.json index 261db47..d94745e 100644 --- a/manifest.json +++ b/manifest.json @@ -46,7 +46,7 @@ { "name": "admin", "type": "user", - "example": "John" + "example": "johndoe" }, { "name": "is_public", @@ -70,7 +70,7 @@ { "name": "password", "type": "password", - "example": "super_secret_password" + "example": "Choose a password" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 7b42e8a..ef945cd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ YNH_PHP_VERSION=7.3 # dependencies used by the app -#extra_php_dependencies=="php${YNH_PHP_VERSION}-gd" +extra_php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index aeebfa9..9b12047 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/change_url b/scripts/change_url index 5285b39..7ac738f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,7 +30,7 @@ ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." @@ -40,7 +40,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -67,6 +67,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf diff --git a/scripts/install b/scripts/install index 722366e..87395c0 100755 --- a/scripts/install +++ b/scripts/install @@ -59,7 +59,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # STANDARD MODIFICATIONS @@ -90,7 +90,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config #--package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= @@ -98,7 +98,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SETUP APPLICATION WITH CURL #================================================= -ynh_script_progression --message="Setting up application with cURL..." +ynh_script_progression --message="Setuping application with CURL..." # Set the app as temporarily public for cURL call ynh_permission_update --permission="main" --add="visitors" diff --git a/scripts/restore b/scripts/restore index cb29f72..95d7db7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -47,7 +47,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -57,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -73,11 +73,11 @@ chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." +ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config #--package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 7f76617..ddf1c7a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,22 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# 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 + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -47,30 +63,14 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# 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 - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path -#================================================= -# STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -92,7 +92,7 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -101,7 +101,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading PHP-FPM configuration..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config #--package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # SPECIFIC UPGRADE