Remove --time flags, they are now implied in CI context

This commit is contained in:
tituspijean 2022-03-03 23:39:04 +01:00
parent d4fa8d57d2
commit 491c801165
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
5 changed files with 80 additions and 80 deletions

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -37,7 +37,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -72,14 +72,14 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -116,14 +116,14 @@ fi
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -131,4 +131,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -50,11 +50,11 @@ app=$YNH_APP_INSTANCE_NAME
### ynh_script_progression will show to your final users the progression of each scripts. ### ynh_script_progression will show to your final users the progression of each scripts.
### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. ### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
### --time is a packager option, it will show you the execution time since the previous call. ### --time is a packager option, it will show you the execution time since the previous call.
### This option should be removed before releasing your app. ### This option is implied when running in CI_package_check, you can manually add it if you are manually testing the app.
### Use the execution time, given by --time, to estimate the weight of a step. ### Use the execution time displayed in the CI report or by adding --time to the command, to estimate the weight of a step.
### A common way to do it is to set a weight equal to the execution time in second +1. ### A common way to do it is to set a weight equal to the execution time in second +1.
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. ### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
ynh_script_progression --message="Validating installation parameters..." --time --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=1
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" ### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
@ -67,7 +67,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --time --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
@ -79,7 +79,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --time --weight=1 ynh_script_progression --message="Finding an available port..." --weight=1
### Use these lines if you have to open a port for the application ### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port. ### `ynh_find_port` will find the first available port starting from the given port.
@ -95,13 +95,13 @@ ynh_app_setting_set --app=$app --key=port --value=$port
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) # If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Open the port # Open the port
# ynh_script_progression --message="Configuring firewall..." --time --weight=1 # ynh_script_progression --message="Configuring firewall..." --weight=1
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port # ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_script_progression --message="Installing dependencies..." --weight=1
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package. ### Those deb packages will be installed as dependencies of this package.
@ -116,7 +116,7 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -124,7 +124,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a MySQL database..." --time --weight=1 ynh_script_progression --message="Creating a MySQL database..." --weight=1
### Use these lines if you need a database for the application. ### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. ### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@ -143,7 +143,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --time --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository. ### downloaded from an upstream source, like a git repository.
@ -166,7 +166,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf ### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -176,7 +176,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --time --weight=1 ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
### `ynh_add_fpm_config` is used to set up a PHP config. ### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP. ### You can remove it if your app doesn't use PHP.
@ -201,7 +201,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --time --weight=1 ynh_script_progression --message="Creating a data directory..." --weight=1
### Use these lines if you need to create a directory to store "persistent files" for the application. ### Use these lines if you need to create a directory to store "persistent files" for the application.
### Usually this directory is used to store uploaded files or any file that won't be updated during ### Usually this directory is used to store uploaded files or any file that won't be updated during
@ -229,7 +229,7 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --time --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
### You can add specific configuration files. ### You can add specific configuration files.
### ###
@ -261,7 +261,7 @@ chown $app:$app "$final_path/some_config_file"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=1
### `ynh_systemd_config` is used to configure a systemd script for an app. ### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd. ### It can be used for apps that use sysvinit (with adaptation) or systemd.
@ -287,12 +287,12 @@ ynh_add_systemd_config
### forms. ### forms.
# Set the app as temporarily public for curl call # Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Making the app public for curl # Making the app public for curl
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
# Installation with curl # Installation with curl
ynh_script_progression --message="Finalizing installation..." --time --weight=1 ynh_script_progression --message="Finalizing installation..." --weight=1
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# Remove the public access # Remove the public access
@ -303,7 +303,7 @@ ynh_permission_update --permission="main" --remove="visitors"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --time --weight=1 ynh_script_progression --message="Configuring log rotation..." --weight=1
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. ### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app. ### Use this helper only if there is effectively a log file for this app.
@ -319,7 +319,7 @@ ynh_use_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
### `yunohost service add` integrates a service in YunoHost. It then gets ### `yunohost service add` integrates a service in YunoHost. It then gets
### displayed in the admin interface and through the others `yunohost service` commands. ### displayed in the admin interface and through the others `yunohost service` commands.
@ -351,7 +351,7 @@ yunohost service add $app --description="A short description of the app" --log="
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
### `ynh_systemd_action` is used to start a systemd service for an app. ### `ynh_systemd_action` is used to start a systemd service for an app.
### Only needed if you have configure a systemd service ### Only needed if you have configure a systemd service
@ -367,7 +367,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --time --weight=1 ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
@ -375,7 +375,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
@ -399,7 +399,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --sho
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -407,4 +407,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --time --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -32,14 +32,14 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." --time --weight=1 ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -47,7 +47,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -55,7 +55,7 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1 ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
@ -63,7 +63,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1 ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -75,14 +75,14 @@ ynh_secure_remove --file="$final_path"
# Remove the data directory if --purge option is used # Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then then
ynh_script_progression --message="Removing app data directory..." --time --weight=1 ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir" ynh_secure_remove --file="$datadir"
fi fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -90,7 +90,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --time --weight=1 ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -98,7 +98,7 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --time --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -109,14 +109,14 @@ ynh_remove_app_dependencies
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_script_progression --message="Closing port $port..." --time --weight=1 ynh_script_progression --message="Closing port $port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --time --weight=1 ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config # Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
@ -126,7 +126,7 @@ ynh_remove_fail2ban_config
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --time --weight=1 ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
@ -142,7 +142,7 @@ ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -151,4 +151,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --time --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -24,7 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -39,7 +39,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -49,14 +49,14 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -64,7 +64,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -81,7 +81,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --time --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$datadir" --not_mandatory
@ -100,14 +100,14 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --time --weight=1 ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --time --weight=1 ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
@ -118,7 +118,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -126,7 +126,7 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 ynh_script_progression --message="Restoring the MySQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -135,7 +135,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." --time --weight=1 ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
@ -144,7 +144,7 @@ ynh_restore_file --origin_path="/etc/$app/"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
@ -152,21 +152,21 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1 ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
@ -175,7 +175,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -184,4 +184,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -38,7 +38,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -54,14 +54,14 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# #
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* # N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
@ -104,7 +104,7 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -115,7 +115,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --time --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
@ -134,7 +134,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -142,14 +142,14 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --time --weight=1 ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
@ -163,7 +163,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --time --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
### Same as during install ### Same as during install
### ###
@ -188,7 +188,7 @@ chown $app:$app "$final_path/some_config_file"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -198,7 +198,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
@ -206,21 +206,21 @@ ynh_use_logrotate --non-append
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# UPGRADE FAIL2BAN # UPGRADE FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --time --weight=1 ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
@ -228,7 +228,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -236,4 +236,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --time --last ynh_script_progression --message="Upgrade of $app completed" --last