From 887e6fcc79bfd71fbd8a97b59f912ef029f90cdf Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 30 Jan 2019 19:13:56 +0100 Subject: [PATCH] Add progression bar --- scripts/_common.sh | 78 ++++++++++++++++++++++++++++ scripts/actions/reset_default_config | 10 ++++ scripts/backup | 12 +++++ scripts/change_url | 13 +++++ scripts/install | 25 ++++++++- scripts/remove | 17 ++++++ scripts/restore | 18 +++++++ scripts/upgrade | 18 +++++++ 8 files changed, 190 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/reset_default_config b/scripts/actions/reset_default_config index c52dd55..43db33f 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" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} query_logging=$(ynh_app_setting_get $app query_logging) @@ -33,6 +34,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" @@ -60,9 +62,17 @@ then # Get the default file and overwrite the current config cp /etc/yunohost/apps/$app/conf/pihole-FTL.conf "$config_file" + ynh_script_progression --message="Restart PiHole" --weight=2 + # Restart pihole-FTL ynh_systemd_action --action=restart --service_name=pihole-FTL fi # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$config_file" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/backup b/scripts/backup index 911bdf3..73cdb10 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 @@ -31,6 +32,7 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # BACKUP THE MAIN APP DIRECTORIES #================================================= +ynh_script_progression --message="Backup the app main directories" --weight=5 CHECK_SIZE "$final_path" ynh_backup "$final_path" @@ -47,12 +49,14 @@ ynh_backup "/opt/pihole" #================================================= # BACKUP NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backup nginx configuration" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Backup php-fpm configuration" ynh_backup "/etc/php5/fpm/pool.d/$app.conf" @@ -61,12 +65,14 @@ ynh_backup "/etc/php5/fpm/pool.d/$app.conf" #================================================= # BACKUP CRON FILE #================================================= +ynh_script_progression --message="Backup cron file" ynh_backup "/etc/cron.d/pihole" #================================================= # BACKUP SPECIFIC FILES #================================================= +ynh_script_progression --message="Backup specific files" ynh_backup "/usr/local/bin/pihole" ynh_backup "/etc/bash_completion.d/pihole" @@ -88,3 +94,9 @@ if test -e "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"; then fi ynh_backup "/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup completed" --last diff --git a/scripts/change_url b/scripts/change_url index 7e0c799..639d46c 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,12 +25,14 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 final_path=$(ynh_app_setting_get $app final_path) #================================================= # 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="/" @@ -39,6 +42,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 @@ -72,6 +76,7 @@ ynh_abort_if_errors #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Modify url in nginx configuration" --weight=4 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -108,13 +113,21 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable 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 abd1c23..5c3885d 100644 --- a/scripts/install +++ b/scripts/install @@ -21,6 +21,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 @@ -33,6 +34,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" final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -46,6 +48,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Store settings from manifest" --weight=3 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -62,6 +65,7 @@ ynh_app_setting_set $app overwrite_phpfpm "1" #================================================= # FIND AND OPEN A PORT #================================================= +ynh_script_progression --message="Find and open a free port" --weight=12 # Find a free port port=$(ynh_find_port 4711) @@ -80,12 +84,14 @@ ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Install dependencies" --weight=12 ynh_install_app_dependencies $app_depencencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Download, check and unpack source" --weight=4 ynh_app_setting_set $app final_path $final_path # Make a copy of local pihole repository (for Gravity) @@ -97,6 +103,7 @@ ynh_setup_source "$final_path" admin_dashboard #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configure nginx" --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -104,6 +111,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 @@ -111,6 +119,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Configure php-fpm" --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -120,6 +129,7 @@ ynh_add_fpm_config #================================================= # CREATE DIRECTORIES AND POPULATE THEM #================================================= +ynh_script_progression --message="Create and populate directories" pihole_storage="/etc/pihole" mkdir -p "$pihole_storage" @@ -138,6 +148,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/" #================================================= # COPY PI-HOLE MAIN SCRIPT #================================================= +ynh_script_progression --message="Copy Pi-Hole main script" cp -a "$pihole_local_repo/pihole" /usr/local/bin/ cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole @@ -171,6 +182,7 @@ sed -i "/# su #/d;" "$pihole_storage/logrotate" #================================================= # INSTALLATION OF PIHOLE-FTL #================================================= +ynh_script_progression --message="Install PiHole-FTL" --weight=30 # Get the source of Pi-Hole-FTL FTL_temp_path=$(mktemp -d) @@ -217,6 +229,7 @@ ynh_store_file_checksum "$setupVars" #================================================= # SET UP DNSMASQ CONFIG #================================================= +ynh_script_progression --message="Set up Dnsmasq config" --weight=2 ynh_systemd_action --action=stop --service_name=dnsmasq @@ -246,6 +259,7 @@ ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf #================================================= # CONFIGURE DNS FOR THE LOCAL DOMAINS #================================================= +ynh_script_progression --message="Configure dns for the local domains" --weight=7 # Find the IP associated to the network interface localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1) @@ -267,6 +281,7 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')" if [ $enable_dhcp -eq 1 ] then + ynh_script_progression --message="Enable dhcp server" max_dhcp_range=250 dhcp_range=100 # Define the dhcp range from the current ip @@ -301,6 +316,7 @@ ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp #================================================= # RESTART DNSMASQ #================================================= +ynh_script_progression --message="Restart Dnsmasq" --time --weight=2 ynh_systemd_action --action=restart --service_name=dnsmasq @@ -315,6 +331,7 @@ ynh_replace_string ".*updatechecker.*" "#&" /etc/cron.d/pihole #================================================= # BUILD THE LISTS WITH GRAVITY #================================================= +ynh_script_progression --message="Build the lists with Gravity" --weight=7 cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default" ynh_exec_warn_less /opt/pihole/gravity.sh @@ -322,6 +339,7 @@ ynh_exec_warn_less /opt/pihole/gravity.sh #================================================= # START PIHOLE-FTL #================================================= +ynh_script_progression --message="Restart PiHole-FTL" --weight=2 ynh_systemd_action --action=restart --service_name=pihole-FTL @@ -342,12 +360,14 @@ yunohost service add pihole-FTL --log "/var/log/pihole-FTL.log" #================================================= # RESTRAIN THE ACCESS TO THE ADMIN ONLY #================================================= +ynh_script_progression --message="Restrain the access to the admin only" --weight=2 yunohost app addaccess --users=$admin $app #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" --weight=4 ynh_systemd_action --action=reload --service_name=nginx @@ -372,5 +392,8 @@ message="${dhcp_alert}You can configure this app easily by using the experimenta You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions. 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/pihole_ynh" +#================================================= +# END OF SCRIPT +#================================================= -ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="install" +ynh_script_progression --message="Installation completed" --last diff --git a/scripts/remove b/scripts/remove index 365d51c..fd657ff 100755 --- 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 @@ -34,6 +35,7 @@ fi #================================================= # STOP PIHOLE-FTL SERVICE #================================================= +ynh_script_progression --message="Stop and remove the service" ynh_systemd_action --action=stop --service_name=pihole-FTL ynh_exec_warn_less systemctl disable pihole-FTL @@ -42,6 +44,7 @@ rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" " #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Remove dependencies" --weight=7 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -49,6 +52,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE THE DIRECTORIES OF THE APP #================================================= +ynh_script_progression --message="Remove app main directories" # Remove storage directory ynh_secure_remove "/etc/pihole" @@ -62,6 +66,7 @@ ynh_secure_remove "/etc/.pihole" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Remove nginx configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -69,6 +74,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Remove php-fpm configuration" --weight=2 # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -76,6 +82,7 @@ ynh_remove_fpm_config #================================================= # CLOSE PORTS #================================================= +ynh_script_progression --message="Close ports" --weight=13 if yunohost firewall list | grep -q "\- $port$" then @@ -115,6 +122,7 @@ ynh_secure_remove "/etc/sudoers.d/pihole" #================================================= # REMOVE DNSMASQ CONFIG #================================================= +ynh_script_progression --message="Remove Dnsmasq config" --weight=2 ynh_systemd_action --action=stop --service_name=dnsmasq rm -f "/etc/dnsmasq.d/01-pihole.conf" @@ -127,6 +135,7 @@ ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf #================================================= # CLEAN /etc/hosts #================================================= +ynh_script_progression --message="Clean /etc/hosts" # Uncomment lines in /etc/hosts sed -i "s/#Commented by pihole# //g" /etc/hosts @@ -137,6 +146,7 @@ sed -i "/#Added by pihole#/d" /etc/hosts #================================================= # RESTART DNSMASQ #================================================= +ynh_script_progression --message="Restart Dnsmasq" ynh_systemd_action --action=restart --service_name=dnsmasq @@ -151,5 +161,12 @@ ynh_secure_remove /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Remove the dedicated user" --weight=2 ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Deletion completed" --last diff --git a/scripts/restore b/scripts/restore index 59f3c07..363bc1d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,6 +21,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -42,6 +43,7 @@ test ! -d $final_path \ #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON @@ -56,6 +58,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE MAIN DIRECTORIES OF THE APP #================================================= +ynh_script_progression --message="Restore the app main directories" ynh_restore_file "$final_path" @@ -68,6 +71,7 @@ ynh_restore_file "/opt/pihole" #================================================= # 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 @@ -90,6 +94,7 @@ ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstall dependencies" --weight=12 ynh_install_app_dependencies $app_depencencies @@ -117,6 +122,7 @@ chown $dnsmasq_user:root /var/log/pihole.log #================================================= # RESTORE SPECIFIC FILES #================================================= +ynh_script_progression --message="Restore specific files" ynh_restore_file "/usr/local/bin/pihole" ynh_restore_file "/etc/bash_completion.d/pihole" @@ -131,6 +137,7 @@ ynh_restore_file "/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app" #================================================= # RESTORE DNSMASQ CONFIG #================================================= +ynh_script_progression --message="Restore Dnsmasq config" ynh_systemd_action --action=stop --service_name=dnsmasq @@ -148,6 +155,7 @@ ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf #================================================= # CONFIGURE DNS FOR THE LOCAL DOMAINS #================================================= +ynh_script_progression --message="Configure dns for the local domains" --weight=2 # Get the default network interface main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}') @@ -168,6 +176,7 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')" #================================================= # RESTART DNSMASQ #================================================= +ynh_script_progression --message="Restart Dnsmasq" ynh_systemd_action --action=restart --service_name=dnsmasq @@ -187,6 +196,7 @@ ynh_store_file_checksum "$setupVars" #================================================= # START PIHOLE-FTL #================================================= +ynh_script_progression --message="Restart PiHole-FTL" --weight=2 ynh_exec_warn_less systemctl enable pihole-FTL ynh_systemd_action --action=restart --service_name=pihole-FTL @@ -196,6 +206,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_script_progression --message="Reload nginx and php-fpm" ynh_systemd_action --action=reload --service_name=php5-fpm ynh_systemd_action --action=reload --service_name=nginx @@ -203,6 +214,7 @@ ynh_systemd_action --action=reload --service_name=nginx #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable maintenance mode" --weight=4 ynh_maintenance_mode_OFF @@ -229,3 +241,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/pihole_ynh" ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="restore" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed" --last diff --git a/scripts/upgrade b/scripts/upgrade index 435675c..2e0c601 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,7 @@ source _variables #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=3 app=$YNH_APP_INSTANCE_NAME @@ -38,6 +39,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensure downward compatibility" # If overwrite_setupvars doesn't exist, create it if [ -z "$overwrite_setupvars" ]; then @@ -66,6 +68,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backup the app before upgrading" --weight=7 # Backup the current version of the app ynh_backup_before_upgrade @@ -86,6 +89,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" ynh_maintenance_mode_ON @@ -94,6 +98,7 @@ ynh_maintenance_mode_ON #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Upgrade dependencies" --weight=6 ynh_install_app_dependencies $app_depencencies @@ -104,6 +109,7 @@ ynh_install_app_dependencies $app_depencencies pihole_local_repo="/etc/.pihole" if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_script_progression --message="Download, check and unpack source" --weight=4 # Update the local copy pihole repository (for Gravity) ynh_setup_source "$pihole_local_repo" # Update admin dashboard @@ -117,6 +123,7 @@ fi # Overwrite the nginx configuration only if it's allowed if [ $overwrite_nginx -eq 1 ] then + ynh_script_progression --message="Reconfigure nginx" --weight=2 # Create a dedicated nginx config ynh_add_nginx_config fi @@ -124,6 +131,7 @@ fi #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Create a dedicated user" # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -135,6 +143,7 @@ ynh_system_user_create $app # Overwrite the php-fpm configuration only if it's allowed if [ $overwrite_phpfpm -eq 1 ] then + ynh_script_progression --message="Reconfigure php-fpm" --weight=3 # Create a dedicated php-fpm config ynh_add_fpm_config fi @@ -155,6 +164,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/" #================================================= # COPY PI-HOLE MAIN SCRIPT #================================================= +ynh_script_progression --message="Copy Pi-Hole main script" cp -a "$pihole_local_repo/pihole" /usr/local/bin/ cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole @@ -180,6 +190,7 @@ sed -i "/# su #/d;" "$pihole_storage/logrotate" #================================================= # UPDATE PIHOLE-FTL #================================================= +ynh_script_progression --message="Upgrade PiHole-FTL" --weight=35 ynh_systemd_action --action=stop --service_name=pihole-FTL @@ -252,6 +263,7 @@ ynh_replace_string ".*updatechecker.*" "#&" /etc/cron.d/pihole #================================================= # START PIHOLE-FTL #================================================= +ynh_script_progression --message="Restart PiHole-FTL" --weight=2 ynh_systemd_action --action=restart --service_name=pihole-FTL @@ -264,12 +276,14 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable maintenance mode" --weight=5 ynh_maintenance_mode_OFF @@ -294,5 +308,9 @@ message="${dhcp_alert}You can configure this app easily by using the experimenta You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions. 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/pihole_ynh" +#================================================= +# END OF SCRIPT +#================================================= ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="upgrade" +ynh_script_progression --message="Upgrade completed" --last