From 7523405a2b0fafc476199cd0dda6af852691889a Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:50:40 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 15 +-------------- scripts/backup | 19 +++++-------------- scripts/change_url | 24 +++++++----------------- scripts/install | 28 +++++++++++----------------- scripts/remove | 18 ++++++------------ scripts/restore | 34 +++++++++++++--------------------- scripts/upgrade | 38 ++++++++++++++------------------------ 8 files changed, 59 insertions(+), 120 deletions(-) diff --git a/manifest.toml b/manifest.toml index dd04569..d1540c2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ website = "https://duniter.org" code = "https://git.duniter.org/nodes/typescript/duniter" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64"] multi_instance = false ldap = "not_relevant" diff --git a/scripts/_common.sh b/scripts/_common.sh index 97bd5c5..19b24a2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,18 +1,13 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= run_duniter() { ynh_exec_as "duniter" duniter --home "$data_dir" "$@" } - CONFIGURE_DUNITER() { run_duniter config --bma --ipv4 127.0.0.1 --port "$port_local_bma" --remoteh $domain --remotep 443 --noupnp @@ -24,11 +19,3 @@ CONFIGURE_DUNITER() { # Add BMAS with path, remove auto-generated BMAS endpoint run_duniter config --addep "BMAS $domain 443 /bma" --remep "BMAS $domain 443" } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index f977a21..8a6baff 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,36 +1,27 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up…" +ynh_print_info "Declaring files to be backed up…" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index bcfc00b..4155bae 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,42 +1,32 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service…" +ynh_script_progression "Stopping a systemd service…" -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration…" +ynh_script_progression "Updating NGINX web server configuration…" -ynh_change_url_nginx_config +ynh_config_change_url_nginx -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service…" +ynh_script_progression "Starting a systemd service…" # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Web administration accessible" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Web administration accessible" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 6d1a3d8..c40a68d 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -14,16 +8,16 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL DUNITER #================================================= -ynh_script_progression --message="Installation of Debian package of Duniter…" +ynh_script_progression "Installation of Debian package of Duniter…" ynh_setup_source --dest_dir="$install_dir" -ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb" -ynh_secure_remove "$install_dir/duniter-server.deb" +ynh_hide_warnings dpkg -i "$install_dir/duniter-server.deb" +ynh_safe_rm "$install_dir/duniter-server.deb" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Configuring a data directory…" +ynh_script_progression "Configuring a data directory…" chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" @@ -31,32 +25,32 @@ chown -R $app:www-data "$data_dir" #================================================= # CONFIGURE DUNITER #================================================= -ynh_script_progression --message="Configure Duniter…" +ynh_script_progression "Configure Duniter…" CONFIGURE_DUNITER #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service…" +ynh_script_progression "Starting a systemd service…" # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Web administration accessible" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Web administration accessible" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 019f79b..d44d605 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,34 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # 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; then +if ynh_hide_warnings yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing Duniter package…" +ynh_script_progression "Removing Duniter package…" dpkg -r duniter @@ -36,4 +30,4 @@ dpkg -r duniter # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ac32d71..167ec3f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,52 +9,50 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL DUNITER #================================================= -ynh_script_progression --message="Installation of Debian package of Duniter…" +ynh_script_progression "Installation of Debian package of Duniter…" ynh_setup_source --dest_dir="$install_dir" -ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb" -ynh_secure_remove "$install_dir/duniter-server.deb" +ynh_hide_warnings dpkg -i "$install_dir/duniter-server.deb" +ynh_safe_rm "$install_dir/duniter-server.deb" #================================================= # CONFIGURE DUNITER #================================================= -ynh_script_progression --message="Configure Duniter…" +ynh_script_progression "Configure Duniter…" CONFIGURE_DUNITER #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet yunohost service add "$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Web administration accessible" +ynh_systemctl --service="$app" --action="start" --log_path="systemd" --wait_until="Web administration accessible" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index a657bb6..f6b6fbd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,27 +1,19 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service…" +ynh_script_progression "Stopping a systemd service…" -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility…" +ynh_script_progression "Ensuring downward compatibility…" if [ -z "$(ls -A "$data_dir")" ]; then mv "/root/.config/duniter"/{,.}* "$data_dir" @@ -29,49 +21,47 @@ if [ -z "$(ls -A "$data_dir")" ]; then chown -R "$app:www-data" "$data_dir" fi -if ynh_compare_current_package_version --comparison lt --version 1.8.7~ynh1; then +if ynh_app_upgrading_from_version_before 1.8.7~ynh1; then run_duniter reset data fi -#================================================= -# SPECIFIC UPGRADE #================================================= # INSTALL DUNITER #================================================= -ynh_script_progression --message="Installation of Debian package of Duniter…" +ynh_script_progression "Installation of Debian package of Duniter…" ynh_setup_source --dest_dir="$install_dir" -ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb" -ynh_secure_remove "$install_dir/duniter-server.deb" +ynh_hide_warnings dpkg -i "$install_dir/duniter-server.deb" +ynh_safe_rm "$install_dir/duniter-server.deb" #================================================= # UPDATE DUNITER CONFIG FILE #================================================= -ynh_script_progression --message="Configure Duniter…" +ynh_script_progression "Configure Duniter…" CONFIGURE_DUNITER #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service…" +ynh_script_progression "Starting a systemd service…" -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Web administration accessible" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Web administration accessible" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"