From dde7ea8add2d932c32d4e3367c2feb4462bb3adf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 23 Nov 2021 08:40:28 +0100 Subject: [PATCH] Fix --- check_process | 6 +++--- conf/app.src | 1 - conf/nginx.conf | 5 ----- manifest.json | 15 ++++----------- scripts/_common.sh | 2 +- scripts/backup | 3 ++- scripts/install | 30 ++++++++++++++++-------------- scripts/restore | 16 +++------------- scripts/upgrade | 38 +++++++++++++++++++------------------- 9 files changed, 48 insertions(+), 68 deletions(-) diff --git a/check_process b/check_process index 5598173..7e60bfa 100644 --- a/check_process +++ b/check_process @@ -1,10 +1,10 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - admin="john" (USER) + domain="domain.tld" + admin="john" admin_password="secret" language="en" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=0 diff --git a/conf/app.src b/conf/app.src index f52595a..7578381 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,3 @@ SOURCE_SUM=7897744356bf81a2bcbc734f132eb5daafa889611c9c72fb2501afb3e9007cac SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/nginx.conf b/conf/nginx.conf index 976e546..337e563 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/public/ ; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - more_set_headers "Strict-Transport-Security: max-age=15768000"; index index.php; diff --git a/manifest.json b/manifest.json index 6e400a0..17a5647 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "jimmy@monin.net" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -26,23 +26,16 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "admin", - "type": "user", - "example": "johndoe" + "type": "user" }, { "name": "admin_password", "type": "password", - "optional": true, - "ask": { - "en": "Set the password for admin user", - "fr": "Définissez le mot de passe pour l'utilisateur" - }, - "example": "supersecretpassword" + "optional": true }, { "name": "is_public", diff --git a/scripts/_common.sh b/scripts/_common.sh index 83c96be..ace8c7d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ YNH_PHP_VERSION="7.3" -extra_php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" +pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 995929f..ae47347 100644 --- a/scripts/backup +++ b/scripts/backup @@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -47,7 +48,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index 1ecbab6..be7a6e1 100644 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= - ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app @@ -56,10 +55,6 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password ynh_app_setting_set --app=$app --key=language --value=$language -#================================================= -# STANDARD MODIFICATIONS -#================================================= - #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -70,6 +65,21 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=4 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -87,21 +97,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=2 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=8 # Create a dedicated php-fpm config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # SPECIFIC SETUP diff --git a/scripts/restore b/scripts/restore index 13e1968..43b7310 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -32,16 +28,14 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -79,11 +73,7 @@ chown -R $app: "${final_path}/.env" "${final_path}/storage/" "${final_path}/boot #================================================= ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=6 -# Restore the file first, so it can have a backup if different -ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" - -# Recreate a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index f5c4674..b8fe082 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,20 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) 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)..." --weight=4 + +# 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 + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -54,18 +68,12 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -# 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 a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # STANDARD UPGRADE STEPS @@ -75,7 +83,7 @@ ynh_abort_if_errors ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Recreate a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # SET MAINTENANCE MODE ON @@ -116,14 +124,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # SPECIFIC UPGRADE #=================================================