From 750ea401950f4e8b3facfa7caa5bc2388b6a4272 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 24 Apr 2020 20:16:33 +0200 Subject: [PATCH] Misc upgrade --- check_process | 5 +- manifest.json | 3 + scripts/actions/check_quota | 9 ++- scripts/actions/clean_images | 9 ++- scripts/actions/clean_ip | 9 ++- scripts/actions/reset_default_config | 14 +++- scripts/change_url | 21 ++--- scripts/config | 117 +++++++++++++++------------ scripts/install | 7 +- scripts/remove | 2 +- scripts/restore | 5 +- scripts/upgrade | 7 +- 12 files changed, 126 insertions(+), 82 deletions(-) diff --git a/check_process b/check_process index e6201ea..44f262b 100644 --- a/check_process +++ b/check_process @@ -18,11 +18,10 @@ port_already_use=1 (8095) change_url=1 ;;; Levels -# Level 5: https://github.com/YunoHost/package_linter/issues/36 - Level 5=1 + Level 5=auto ;;; Options Email= -Notification=down +Notification=change ;;; Upgrade options ; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d diff --git a/manifest.json b/manifest.json index cc0267a..c5929a3 100644 --- a/manifest.json +++ b/manifest.json @@ -49,6 +49,9 @@ "fr": "L'upload des images est-il public ?" }, "default": false, + "help": { + "en": "If you set Lutim as public, everyone will be able to upload images and share them.
But even if not public, everyone can see an image from a link shared with your Lutim." + } }, { "name": "always_encrypt", diff --git a/scripts/actions/check_quota b/scripts/actions/check_quota index bd5d58b..dccf93d 100755 --- a/scripts/actions/check_quota +++ b/scripts/actions/check_quota @@ -9,11 +9,18 @@ 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} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) diff --git a/scripts/actions/clean_images b/scripts/actions/clean_images index b671415..73eb953 100755 --- a/scripts/actions/clean_images +++ b/scripts/actions/clean_images @@ -9,11 +9,18 @@ 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} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) diff --git a/scripts/actions/clean_ip b/scripts/actions/clean_ip index 8e7db98..fa70070 100755 --- a/scripts/actions/clean_ip +++ b/scripts/actions/clean_ip @@ -9,11 +9,18 @@ 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} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index 7526268..f7239cf 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -9,11 +9,23 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { +# Clean installation remaining that are not handle by the remove script. + ynh_clean_check_starting +} +# 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} +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) path_url=$(ynh_app_setting_get --app=$app --key=path) diff --git a/scripts/change_url b/scripts/change_url index 369918d..8bb481c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -38,11 +38,13 @@ ynh_script_progression --message="Backing up the app before changing its url (ma # Backup the current version of the app ynh_backup_before_upgrade 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" + ynh_clean_check_starting - # restore it if the upgrade fails - ynh_restore_upgradebackup + # 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 + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -72,17 +74,6 @@ then change_path=1 fi -#================================================= -# MANAGE FAILURE OF THE SCRIPT -#================================================= - -ynh_clean_setup () { -# Clean installation remaining that are not handle by the remove script. - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD MODIFICATIONS #================================================= diff --git a/scripts/config b/scripts/config index 8162129..550874d 100644 --- a/scripts/config +++ b/scripts/config @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -43,9 +43,11 @@ get_config_value() { # always_encrypt old_always_encrypt="$(get_config_value always_encrypt)" always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}" + # antiflood old_antiflood="$(get_config_value anti_flood_delay)" antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}" + # delay old_delay="$(get_config_value default_delay)" if [ $old_delay -eq 0 ]; then @@ -101,62 +103,75 @@ show_config() { #================================================= apply_config() { - restart_lutim=0 - # Change configuration if needed - # always_encrypt - if [ "$always_encrypt" != "$old_always_encrypt" ] - then - ynh_replace_string --match_string=".*always_encrypt *=>.*" --replace_string=" always_encrypt => $always_encrypt," --target_file="$config_file" - restart_lutim=1 - fi + #================================================= + # MODIFY LUTIM CONFIGURATION + #================================================= - # antiflood - if [ "$antiflood" != "$old_antiflood" ] - then - ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$config_file" - # Disable anti_flood_delay if the delay is 0 - if [ $antiflood = 0 ]; then - ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$config_file" - fi - ynh_app_setting_set --app=$app --key=antiflood --value="$antiflood" - restart_lutim=1 - fi + restart_lutim=0 - # delay - if [ "$delay" != "$old_delay" ] - then - if [ $delay = None ]; then - delay=0 - elif [ $delay = Day ]; then - delay=1 - elif [ $delay = Week ]; then - delay=7 - elif [ $delay = Month ]; then - delay=30 - else - delay=360 - fi - ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=delay --value="$delay" - restart_lutim=1 - fi + # Change configuration if needed + # always_encrypt + if [ "$always_encrypt" != "$old_always_encrypt" ] + then + ynh_replace_string --match_string=".*always_encrypt *=>.*" --replace_string=" always_encrypt => $always_encrypt," --target_file="$config_file" + restart_lutim=1 + fi - if [ $restart_lutim -eq 1 ] - then - # Wait for lutim to be fully started - ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" - fi + # antiflood + if [ "$antiflood" != "$old_antiflood" ] + then + ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$config_file" + # Disable anti_flood_delay if the delay is 0 + if [ $antiflood = 0 ]; then + ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$config_file" + fi + ynh_app_setting_set --app=$app --key=antiflood --value="$antiflood" + restart_lutim=1 + fi - # Set overwrite_settings - ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" - # Set overwrite_nginx - ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" - # Set overwrite_systemd - ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd" + # delay + if [ "$delay" != "$old_delay" ] + then + if [ $delay = None ]; then + delay=0 + elif [ $delay = Day ]; then + delay=1 + elif [ $delay = Week ]; then + delay=7 + elif [ $delay = Month ]; then + delay=30 + else + delay=360 + fi + ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=delay --value="$delay" + restart_lutim=1 + fi - # Set admin_mail_html - ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" + if [ $restart_lutim -eq 1 ] + then + # Wait for lutim to be fully started + ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" + fi + + #================================================= + # MODIFY OVERWRITTING SETTINGS + #================================================= + + # Set overwrite_settings + ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" + # Set overwrite_nginx + ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" + # Set overwrite_systemd + ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd" + + #================================================= + # MODIFY EMAIL SETTING + #================================================= + + # Set admin_mail_html + ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" } #================================================= diff --git a/scripts/install b/scripts/install index 8364344..e0e519b 100644 --- a/scripts/install +++ b/scripts/install @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE FAILURE OF THE SCRIPT #================================================= @@ -259,4 +260,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 8480254..5c04deb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -94,4 +94,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 170efbc..d522562 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source ../settings/scripts/_variables +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE SCRIPT FAILURE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d16892d..309da4b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # LOAD SETTINGS #================================================= @@ -209,7 +210,7 @@ ynh_system_user_create --username=$app #================================================= # SETUP LUTIM #================================================= -ynh_script_progression --message="Reconfigure Lutim" +ynh_script_progression --message="Reconfiguring Lutim..." # Overwrite the settings config file only if it's allowed if [ $overwrite_settings -eq 1 ]