From ea1ab4920eed58c509bb0096291b37ed6b0b49c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 24 Dec 2022 11:30:09 +0100 Subject: [PATCH] Fix linter --- manifest.json | 2 +- scripts/config | 26 ++++++++++++++++++++++++-- scripts/install | 7 ++++++- scripts/restore | 3 +++ scripts/upgrade | 30 ++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 9b182f2..dedf612 100644 --- a/manifest.json +++ b/manifest.json @@ -26,7 +26,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.3-fpm" + "php8.0-fpm" ], "arguments": { "install" : [ diff --git a/scripts/config b/scripts/config index c6fd0b8..2f97706 100644 --- a/scripts/config +++ b/scripts/config @@ -67,7 +67,29 @@ set__free_footprint() { # GENERIC FINALIZATION #================================================= -ynh_app_config_validate -ynh_app_config_apply +ynh_app_config_validate() { + _ynh_app_config_validate + + if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then + # If fpm_footprint is set to 'specific', use $fpm_free_footprint value. + if [ "$fpm_footprint" = "specific" ] + then + fpm_footprint=$fpm_free_footprint + fi + + if [ "$fpm_footprint" == "0" ] + then + ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." + + exit 0 + fi + fi +} + +ynh_app_config_apply() { + _ynh_app_config_apply + + ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint +} ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 1a7b3c3..04d1a02 100755 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,10 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME +fpm_footprint="low" +fpm_free_footprint=0 +fpm_usage="low" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -80,7 +84,8 @@ chmod g+w $final_path/data/cache $final_path/data/favicons $final_path/data/logs ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low +ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 89b2aed..ca30898 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) + #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d72ae70..17b7f7e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= @@ -44,6 +45,35 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +# If fpm_footprint doesn't exist, create it +if [ -z "$fpm_footprint" ]; then + fpm_footprint=low + ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint +fi + +# If fpm_free_footprint doesn't exist, create it +if [ -z "$fpm_free_footprint" ]; then + fpm_free_footprint=0 + ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint +fi + +# If fpm_usage doesn't exist, create it +if [ -z "$fpm_usage" ]; then + fpm_usage=low + ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +fi + #================================================= # CREATE DEDICATED USER #=================================================