From 00e313cb46a0cb8435403dec5d05a885a74d2ad8 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 8 Apr 2020 12:47:32 +0200 Subject: [PATCH] Fixes for actions and config-panel --- check_process | 14 ++++++++++++++ scripts/actions/create_database | 11 +++++++++-- scripts/actions/public_private | 7 +++++++ scripts/actions/remove_database | 11 +++++++++-- scripts/actions/sftp | 7 +++++++ scripts/config | 28 ++++++++++++++++++++-------- 6 files changed, 66 insertions(+), 12 deletions(-) diff --git a/check_process b/check_process index 755c485..9040f30 100644 --- a/check_process +++ b/check_process @@ -6,6 +6,18 @@ password="myreallystrengthpassword" is_public=1 (PUBLIC|public=1|private=0) with_mysql=1 + ; Actions + with_sftp=1|0 + is_public=1|0 + ; Config_panel + main.sftp.sftp=1|0 + main.sftp.password=password1 + main.is_public.is_public=1|0 + main.overwrite_files.overwrite_nginx=1|0 + main.overwrite_files.overwrite_phpfpm=1|0 + main.php_fpm_config.footprint=low|medium|high + main.php_fpm_config.free_footprint=20 + main.php_fpm_config.usage=low|medium|high ; Checks pkg_linter=1 setup_sub_dir=1 @@ -19,6 +31,8 @@ multi_instance=1 port_already_use=0 change_url=1 + actions=1 + config_panel=1 ;; Test without sftp ; Manifest domain="domain.tld" (DOMAIN) diff --git a/scripts/actions/create_database b/scripts/actions/create_database index f8ddb6f..428fa01 100755 --- a/scripts/actions/create_database +++ b/scripts/actions/create_database @@ -9,15 +9,22 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} - #================================================= # CHECK IF ARGUMENTS ARE CORRECT #================================================= diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 778a6a3..9d164aa 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/actions/remove_database b/scripts/actions/remove_database index d7c4477..09f784d 100755 --- a/scripts/actions/remove_database +++ b/scripts/actions/remove_database @@ -10,13 +10,20 @@ source scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# RETRIEVE ARGUMENTS +# MANAGE SCRIPT FAILURE #================================================= -with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) + #================================================= # CHECK IF ARGUMENTS ARE CORRECT #================================================= diff --git a/scripts/actions/sftp b/scripts/actions/sftp index da2aede..ba5cdb6 100755 --- a/scripts/actions/sftp +++ b/scripts/actions/sftp @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/config b/scripts/config index 104c718..ff6c0a6 100644 --- a/scripts/config +++ b/scripts/config @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +source _ynh_add_fpm_config #================================================= # RETRIEVE ARGUMENTS @@ -33,15 +34,18 @@ with_sftp="${YNH_CONFIG_MAIN_SFTP_SFTP:-$old_with_sftp}" # sftp password is_password_exist=0 ynh_print_OFF; password=$(ynh_app_setting_get --app=$app --key=password) -if [ -n "$password" ] +if [ -n "$YNH_CONFIG_MAIN_SFTP_PASSWORD" ] then - ynh_print_warn --message="A password already exist, it will not be replaced." - # If a password already exist, unset the variable password and to not change it. - unset password - is_password_exist=1 -else - # Otherwise, get the new password - password="$YNH_CONFIG_MAIN_SFTP_PASSWORD" + if [ -n "$password" ] + then + ynh_print_warn --message="A password already exist, it will not be replaced." + # If a password already exist, unset the variable password and to not change it. + unset password + is_password_exist=1 + else + # Otherwise, get the new password + password="$YNH_CONFIG_MAIN_SFTP_PASSWORD" + fi fi ynh_print_ON @@ -144,6 +148,14 @@ apply_config() { if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] then ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + + user=$(ynh_app_setting_get --app=$app --key=user) + # use $user instead of $app as user that run the fpm processes + finalphpconf="/etc/php/7.0/fpm/pool.d/$app.conf" + ynh_replace_string --match_string="^user = .*" --replace_string="user = $user" --target_file="$finalphpconf" + ynh_replace_string --match_string="^group = .*" --replace_string="group = $user" --target_file="$finalphpconf" + + ynh_systemd_action --service_name=php7.0-fpm --action=reload fi }