From 8693bbb6b75426bc79e75cd09bca1f8178414f3f Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:07:59 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 14 +------------- scripts/backup | 21 ++++++--------------- scripts/install | 26 ++++++++++---------------- scripts/remove | 24 +++++++++--------------- scripts/restore | 28 ++++++++++------------------ scripts/upgrade | 40 +++++++++++++++------------------------- 7 files changed, 53 insertions(+), 103 deletions(-) diff --git a/manifest.toml b/manifest.toml index 804eaee..d9b979c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,7 +20,8 @@ code = "https://github.com/eclipse/mosquitto" cpe = "cpe:2.3:a:eclipse:mosquitto" [integration] -yunohost = ">= 11.2.20" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false ldap = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 030a73e..a084af2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,19 +1,10 @@ #!/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..." #================================================= # SPECIFIC BACKUP @@ -21,22 +12,22 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP VARIOUS FILES #================================================= # Backup the passwd file -ynh_backup --src_path="/etc/mosquitto/passwd" +ynh_backup "/etc/mosquitto/passwd" # Backup the config file -ynh_backup --src_path="/etc/mosquitto/conf.d/default.conf" +ynh_backup "/etc/mosquitto/conf.d/default.conf" -ynh_backup --src_path="/var/log/$app/" +ynh_backup "/var/log/$app/" #================================================= # 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/install b/scripts/install index fe9c6e0..24c0ee7 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,20 +8,20 @@ source /usr/share/yunohost/helpers #================================================= # Passwords aren't saved by default -ynh_app_setting_set --app="$app" --key=userpass --value="$userpass" +ynh_app_setting_set --key=userpass --value="$userpass" #================================================= # SPECIFIC SETUP #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" -ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd" +ynh_config_add --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" +ynh_config_add --template="passwd" --destination="/etc/mosquitto/passwd" mosquitto_passwd -U "/etc/mosquitto/passwd" -ynh_store_file_checksum --file="/etc/mosquitto/passwd" +ynh_store_file_checksum "/etc/mosquitto/passwd" # Hard coded username because deb package creates the user chown -R "mosquitto" "/etc/mosquitto" @@ -35,23 +29,23 @@ chown -R "mosquitto" "/etc/mosquitto" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="restart" +ynh_systemctl --service="$app" --action="restart" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 4227790..e880bc3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,48 +1,42 @@ #!/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 # It seems the simple stop is not enough… -ynh_systemd_action --service_name="$app" --action="stop" +ynh_systemctl --service="$app" --action="stop" pkill -u "$app" || true -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." --weight=1 +ynh_script_progression "Removing various files..." # Remove the passwd file -ynh_secure_remove --file="/etc/mosquitto/passwd" +ynh_safe_rm "/etc/mosquitto/passwd" # Remove the config file -ynh_secure_remove --file="/etc/mosquitto/conf.d/default.conf" +ynh_safe_rm "/etc/mosquitto/conf.d/default.conf" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index efa60c8..da4c4cb 100755 --- 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 @@ -13,37 +7,35 @@ source /usr/share/yunohost/helpers #================================================= # 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/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 +ynh_script_progression "Restoring various files..." -ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf" -ynh_restore_file --origin_path="/etc/mosquitto/passwd" +ynh_restore "/etc/mosquitto/conf.d/default.conf" +ynh_restore "/etc/mosquitto/passwd" -ynh_restore_file --origin_path="/var/log/$app/" +ynh_restore "/var/log/$app/" # Hard coded username because deb package creates the user chown -R "mosquitto" "/etc/mosquitto" -chown -R "mosquitto" "/var/log/$app/" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "mosquitto" "/var/log/$app/" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" +ynh_systemctl --service="$app" --action="restart" -#================================================= -# GENERIC FINALIZATION #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 516bae8..7d3f96c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,48 +1,38 @@ #!/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 $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" +ynh_systemctl --service="$app" --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # Transfer and delete the old "password" key if [ -z "${userpass:-}" ]; then userpass="$password" - ynh_app_setting_set --app="$app" --key="userpass" --value="$userpass" - ynh_app_setting_delete --app="$app" --key="password" + ynh_app_setting_set --key="userpass" --value="$userpass" + ynh_app_setting_delete --key="password" fi -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" +ynh_config_add --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" -ynh_delete_file_checksum --file="/etc/mosquitto/passwd" -ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd" +ynh_delete_file_checksum "/etc/mosquitto/passwd" +ynh_config_add --template="passwd" --destination="/etc/mosquitto/passwd" mosquitto_passwd -U "/etc/mosquitto/passwd" -ynh_store_file_checksum --file="/etc/mosquitto/passwd" +ynh_store_file_checksum "/etc/mosquitto/passwd" # Hard coded username because deb package creates the user chown -R "mosquitto" "/etc/mosquitto" @@ -50,22 +40,22 @@ chown -R "mosquitto" "/etc/mosquitto" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" +ynh_systemctl --service="$app" --action="restart" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"