From 6b63a2ce2feca4550e55f2404e8b18f13ef58fc7 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 30 Jan 2019 16:19:40 +0100 Subject: [PATCH] Add progression bar --- scripts/_common.sh | 78 ++++++++++++++++++++++++++++ scripts/actions/check_quota | 8 +++ scripts/actions/clean_images | 8 +++ scripts/actions/clean_ip | 8 +++ scripts/actions/public_private | 14 +++++ scripts/actions/reset_default_config | 11 ++++ scripts/backup | 12 +++++ scripts/change_url | 15 ++++++ scripts/install | 20 +++++++ scripts/remove | 12 +++++ scripts/restore | 15 ++++++ scripts/upgrade | 22 +++++++- 12 files changed, 222 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index caf8bc7..278d8c7 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -629,6 +629,84 @@ ynh_clean_check_starting () { #================================================= +# Print a message as INFO and show progression during an app script +# +# usage: ynh_script_progression --message=message [--weight=weight] [--time] +# | arg: -m, --message= - The text to print +# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script. +# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights. +# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar. +increment_progression=0 +previous_weight=0 +# Define base_time when the file is sourced +base_time=$(date +%s) +ynh_script_progression () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last ) + local message + local weight + local time + local last + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + weight=${weight:-1} + time=${time:-0} + last=${last:-0} + + # Get execution time since the last $base_time + local exec_time=$(( $(date +%s) - $base_time )) + base_time=$(date +%s) + + # Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented. + local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)" + # Get the number of call with a weight value + local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0) + + # Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight + local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')" + # Get the weight of each occurrences of 'ynh_script_progression' in the script using -w + local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')" + # Each value will be on a different line. + # Remove each 'end of line' and replace it by a '+' to sum the values. + local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 )) + + # max_progression is a total number of calls to this helper. + # Less the number of calls with a weight value. + # Plus the total of weight values + local max_progression=$(( $helper_calls - $weight_calls + $weight_values )) + + # Increment each execution of ynh_script_progression in this script by the weight of the previous call. + increment_progression=$(( $increment_progression + $previous_weight )) + # Store the weight of the current call in $previous_weight for next call + previous_weight=$weight + + # Set the scale of the progression bar + local scale=20 + # progress_string(1,2) should have the size of the scale. + local progress_string1="####################" + local progress_string0="...................." + + # Reduce $increment_progression to the size of the scale + if [ $last -eq 0 ] + then + local effective_progression=$(( $increment_progression * $scale / $max_progression )) + # If last is specified, fill immediately the progression_bar + else + local effective_progression=$scale + fi + + # Build $progression_bar from progress_string(1,2) according to $effective_progression + local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}" + + local print_exec_time="" + if [ $time -eq 1 ] + then + print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]" + fi + + ynh_print_info "[$progression_bar] > ${message}${print_exec_time}" +} + # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] diff --git a/scripts/actions/check_quota b/scripts/actions/check_quota index db5c144..627dab3 100755 --- a/scripts/actions/check_quota +++ b/scripts/actions/check_quota @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} @@ -30,5 +31,12 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK THE DISK QUOTA FOR IMAGES STORED BY LUTIM #================================================= +ynh_script_progression --message="Check the disk quota for images stored by lutim" --weight=9 (cd "$final_path" && $(which carton) exec script/lutim cron watch) + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/clean_images b/scripts/actions/clean_images index a27a5b9..098fc70 100755 --- a/scripts/actions/clean_images +++ b/scripts/actions/clean_images @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} @@ -30,5 +31,12 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE EXPIRED IMAGES #================================================= +ynh_script_progression --message="Remove expired images" --weight=9 (cd "$final_path" && $(which carton) exec script/lutim cron cleanfiles) + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/clean_ip b/scripts/actions/clean_ip index 45515d0..d40adbf 100755 --- a/scripts/actions/clean_ip +++ b/scripts/actions/clean_ip @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} @@ -30,5 +31,12 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE OBSOLETE IP FROM THE DATABASE #================================================= +ynh_script_progression --message="Remove obsolete ip from the database" --weight=9 (cd "$final_path" && $(which carton) exec script/lutim cron cleanbdd) + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 30fb19e..bfb74ae 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" # Get is_public is_public=${YNH_ACTION_IS_PUBLIC} @@ -40,6 +41,12 @@ fi #================================================= # MOVE TO PUBLIC OR PRIVATE #================================================= +if [ $is_public -eq 0 ]; then + public_private="private" +else + public_private="public" +fi +ynh_script_progression --message="Move the application to $public_private" --weight=3 if [ $is_public -eq 0 ] then @@ -64,5 +71,12 @@ ynh_app_setting_set $app is_public $is_public #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index 4fef116..87ad555 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" --weight=3 app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} final_path=$(ynh_app_setting_get $app final_path) @@ -36,6 +37,7 @@ fi #================================================= # RESET THE CONFIG FILE #================================================= +ynh_script_progression --message="Reset the config file $config_file" --weight=9 # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different "$config_file" @@ -56,5 +58,14 @@ fi # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$config_file" +ynh_script_progression --message="Restart Lutim" --weight=5 + # 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" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last + diff --git a/scripts/backup b/scripts/backup index beee673..920c5f0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -30,6 +31,7 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_script_progression --message="Backup the app main dir" --weight=4 CHECK_SIZE "$final_path" ynh_backup "$final_path" @@ -37,6 +39,7 @@ ynh_backup "$final_path" #================================================= # BACKUP NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backup nginx configuration" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -45,17 +48,26 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= +ynh_script_progression --message="Backup logrotate configuration" ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= +ynh_script_progression --message="Backup systemd configuration" ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP A CRON FILE #================================================= +ynh_script_progression --message="Backup cron file" ynh_backup "/etc/cron.d/$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup completed" --last diff --git a/scripts/change_url b/scripts/change_url index f284e84..c913314 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -24,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 final_path=$(ynh_app_setting_get $app final_path) is_public=$(ynh_app_setting_get $app is_public) @@ -32,6 +34,7 @@ port=$(ynh_app_setting_get $app port) #================================================= # CHECK THE SYNTAX OF THE PATHS #================================================= +ynh_script_progression --message="Check the syntax of the paths" test -n "$old_path" || old_path="/" test -n "$new_path" || new_path="/" @@ -41,6 +44,7 @@ old_path=$(ynh_normalize_url_path $old_path) #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" path_url=$old_path domain=$old_domain @@ -78,6 +82,7 @@ ynh_abort_if_errors #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Modify url in nginx configuration" --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -112,6 +117,7 @@ fi #================================================= # UPDATE SSOWAT #================================================= +ynh_script_progression --message="Reconfigure SSOwat" if [ $is_public -eq 0 ] then @@ -138,12 +144,14 @@ ynh_replace_string "\(^ *prefix.*=> '\).*" "\1$new_path'," "$final_path/lutim.co #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" --weight=2 ynh_systemd_action --action=reload --service_name=nginx #================================================= # START AND CHECK LUTIM BOOTING #================================================= +ynh_script_progression --message="Restart Lutim" --weight=3 # 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" @@ -151,7 +159,14 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path=" #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Deactive maintenance mode" --weight=5 path_url=$old_path domain=$old_domain ynh_maintenance_mode_OFF + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of url completed" --last diff --git a/scripts/install b/scripts/install index e51f0a3..3576004 100644 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -35,6 +36,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS #================================================= +ynh_script_progression --message="Check if the app can be installed" --weight=2 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -48,6 +50,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Store settings from manifest" --weight=2 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app is_public $is_public @@ -61,6 +64,7 @@ ynh_app_setting_set $app overwrite_systemd "1" #================================================= # FIND AND OPEN A PORT #================================================= +ynh_script_progression --message="Find a free port" --weight=3 # Find a free port port=$(ynh_find_port 8095) @@ -79,12 +83,14 @@ ynh_setup_source "$final_path" #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Install dependencies" --weight=60 ynh_install_app_dependencies $app_depencencies #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configure nginx" --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -92,6 +98,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Create a dedicated user" --weight=2 # Create a dedicated system user ynh_system_user_create $app @@ -101,6 +108,7 @@ ynh_system_user_create $app #================================================= # SETUP LUTIM #================================================= +ynh_script_progression --message="Configure Lutim" --weight=2 # Configure Lutim cp ../conf/lutim.conf.template "$final_path/lutim.conf" @@ -117,6 +125,7 @@ ynh_store_file_checksum "$final_path/lutim.conf" #================================================= # SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configure systemd" --weight=2 # Create a dedicated systemd config ynh_add_systemd_config @@ -132,6 +141,7 @@ chmod +x $final_path/script/lutim #================================================= # INSTALL LUTIM WITH CARTON #================================================= +ynh_script_progression --message="Install Lutim with Carton" --weight=60 mkdir -p /var/log/$app/ (cd $final_path @@ -166,6 +176,7 @@ chown -R $app: $final_path #================================================= # SETUP LOGROTATE #================================================= +ynh_script_progression --message="Configure logrotate" --weight=2 # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -179,6 +190,7 @@ yunohost service add lutim -l $final_path/log/production.log #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Setup SSOwat" ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ] @@ -196,12 +208,14 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" --weight=2 ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK LUTIM BOOTING #================================================= +ynh_script_progression --message="Restart Lutim" --weight=6 # 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" @@ -224,3 +238,9 @@ You can also find some specific actions for this app by using the experimental a If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" ynh_send_readme_to_admin --app_message="$message" --recipients="root" --type="install" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation completed" --last diff --git a/scripts/remove b/scripts/remove index 36e6234..346dc92 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -22,6 +23,7 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # STOP AND REMOVE SERVICE #================================================= +ynh_script_progression --message="Stop and remove the service" --weight=6 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -40,6 +42,7 @@ fi #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Remove dependencies" --weight=20 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -47,6 +50,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Remove app main directory" --weight=2 # Remove the app directory securely ynh_secure_remove "/var/www/$app" @@ -54,6 +58,7 @@ ynh_secure_remove "/var/www/$app" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Remove nginx configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -61,6 +66,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Remove logrotate configuration" # Remove the app-specific logrotate config ynh_remove_logrotate @@ -72,3 +78,9 @@ ynh_remove_logrotate #================================================= ynh_secure_remove "/etc/cron.d/$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Deletion completed" --last diff --git a/scripts/restore b/scripts/restore index 67b9af7..f00c438 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,6 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -44,6 +45,7 @@ test ! -d $final_path \ #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON @@ -58,12 +60,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restore the app main directory" ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreate the dedicated user" --weight=2 # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -80,6 +84,7 @@ chown -R $app: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstall dependencies" --weight=60 ynh_install_app_dependencies $app_depencencies @@ -92,6 +97,7 @@ yunohost service add $app --log "/var/log/$app/APP.log" #================================================= # RESTORE SYSTEMD #================================================= +ynh_script_progression --message="Restore the systemd configuration" ynh_restore_file "/etc/systemd/system/$app.service" systemctl enable $app.service @@ -122,12 +128,14 @@ ynh_restore_file "/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" --weight=2 ynh_systemd_action --action=reload --service_name=nginx #================================================= # START AND CHECK LUTIM BOOTING #================================================= +ynh_script_progression --message="Restart Lutim" --weight=3 # 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" @@ -135,6 +143,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path=" #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Deactive maintenance mode" --weight=7 ynh_maintenance_mode_OFF @@ -153,3 +162,9 @@ You can also find some specific actions for this app by using the experimental a If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" ynh_send_readme_to_admin --app_message="$message" --recipients="root" --type="restore" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed" --last diff --git a/scripts/upgrade b/scripts/upgrade index 2cc37e7..b2db90b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,7 @@ source _variables #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=4 app=$YNH_APP_INSTANCE_NAME @@ -41,6 +42,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensure downward compatibility" --weight=2 # Fix is_public as a boolean if [ "$is_public" = "Yes" ]; then @@ -94,6 +96,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backup the app before upgrading" --weight=15 # Backup the current version of the app ynh_backup_before_upgrade @@ -116,6 +119,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON @@ -127,6 +131,7 @@ ynh_maintenance_mode_ON if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_script_progression --message="Download, check and unpack source" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" fi @@ -134,6 +139,7 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= +ynh_script_progression --message="Upgrade dependencies" --weight=9 ynh_install_app_dependencies $app_depencencies @@ -144,12 +150,14 @@ ynh_install_app_dependencies $app_depencencies # Overwrite the nginx configuration only if it's allowed if [ $overwrite_nginx -eq 1 ] then + ynh_script_progression --message="Reconfigure nginx" --weight=2 ynh_add_nginx_config fi #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Create a dedicated user" # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -159,6 +167,7 @@ ynh_system_user_create $app #================================================= # SETUP LUTIM #================================================= +ynh_script_progression --message="Reconfigure Lutim" # Overwrite the settings config file only if it's allowed if [ $overwrite_settings -eq 1 ] @@ -195,6 +204,7 @@ fi # Overwrite the systemd configuration only if it's allowed if [ $overwrite_systemd -eq 1 ] then + ynh_script_progression --message="Reconfigure systemd" --weight=2 ynh_add_systemd_config fi @@ -211,6 +221,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" /etc/cron.d/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_script_progression --message="Upgrade Lutim with carton" --weight=4 (cd $final_path carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log") fi @@ -227,6 +238,7 @@ chown -R $app: $final_path #================================================= # SETUP LOGROTATE #================================================= +ynh_script_progression --message="Reconfigure logrotate" ynh_use_logrotate --non-append chown $app -R /var/log/$app @@ -234,6 +246,7 @@ chown $app -R /var/log/$app #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Reconfigure SSOwat" ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ] @@ -247,12 +260,14 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # START AND CHECK LUTIM BOOTING #================================================= +ynh_script_progression --message="Restart Lutim" --weight=4 # 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" @@ -260,6 +275,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path=" #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Deactive maintenance mode" --weight=7 ynh_maintenance_mode_OFF @@ -277,4 +293,8 @@ You can also find some specific actions for this app by using the experimental a If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" -ynh_send_readme_to_admin --app_message="$message" --recipients="root" --type="upgrade" +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade completed" --last