From 3c8cd2d9e211f6035f260f8df9f3c045c6e0dc98 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 2 Jul 2021 21:50:21 +0200 Subject: [PATCH] Fix --- scripts/backup | 17 +++++++++++------ scripts/install | 15 +++++++++++---- scripts/restore | 9 ++++++--- scripts/upgrade | 6 ++++-- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/scripts/backup b/scripts/backup index 073460e..3c04a8f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,6 +13,11 @@ 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 #================================================= @@ -37,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP CONFIG +#================================================= + +ynh_backup --src_path="$config_path" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -49,12 +60,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP CONFIG -#================================================= - -ynh_backup --src_path="$config_path" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 6bfa028..62945b4 100644 --- a/scripts/install +++ b/scripts/install @@ -111,12 +111,20 @@ ynh_app_setting_set --app=$app --key=$config_path --value=$config_path mkdir -p $config_path -ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" - chmod 750 "$config_path" chmod -R o-rwx "$config_path" chown -R $app:www-data "$config_path" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" + +chmod 400 "$config_path/config.js" +chown $app "$config_path/config.js" + #================================================= # INSTALL THE LOUNGE #================================================= @@ -124,7 +132,7 @@ ynh_script_progression --message="Installing The Lounge..." pushd $final_path ynh_use_nodejs - yarn install + ynh_exec_warn_less yarn install ynh_exec_warn_less NODE_ENV=production yarn build popd @@ -134,7 +142,6 @@ popd ynh_script_progression --message="Configuring a systemd service..." ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config diff --git a/scripts/restore b/scripts/restore index f097299..c2be51a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,7 +14,8 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + #### 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 @@ -61,7 +62,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring $app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" @@ -74,7 +75,9 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Restoring the config path..." -ynh_restore_file --origin_path="$config_path" +ynh_restore_file --origin_path="$config_path" --not_mandatory + +mkdir -p $config_path chmod 750 "$config_path" chmod -R o-rwx "$config_path" diff --git a/scripts/upgrade b/scripts/upgrade index 6716dc5..b02e2d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -134,7 +134,7 @@ then ynh_script_progression --message="Upgrading the lounge..." pushd $final_path ynh_use_nodejs - yarn install + ynh_exec_warn_less yarn install ynh_exec_warn_less NODE_ENV=production yarn build popd fi @@ -146,13 +146,15 @@ ynh_script_progression --message="Modifying a config file..." ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" +chmod 400 "$config_path/config.js" +chown $app "$config_path/config.js" + #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config