From 8860b227f48c9ba5f15d012f1b7ca17b1c33a929 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:41:13 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 2 ++ manifest.toml | 3 ++- scripts/_common.sh | 16 ++-------------- scripts/backup | 17 +++++++---------- scripts/install | 30 +++++++++++++++--------------- scripts/remove | 20 ++++++++++---------- scripts/restore | 28 ++++++++++++++-------------- scripts/upgrade | 26 +++++++++++++------------- 8 files changed, 65 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index d38c149..0f5a9f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.swp *~ +*.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index 71e6c85..0b7b8c4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ admindoc = "https://doc.biboumi.louiz.org" code = "https://github.com/louiz/biboumi" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 1b0062a..318670f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= _get_metronome_config_dir() { @@ -17,17 +13,9 @@ _get_metronome_config_dir() { # multi_instance=false, there's only one metronome_app=$(yunohost app list --json | jq -r '.apps[] | select(.id == "metronome") | .id') if [[ -z "${metronome_app:-}" ]]; then - ynh_print_warn --message="Could not find any metronome app!" + ynh_print_warn "Could not find any metronome app!" return 1 fi echo "$(ynh_app_setting_get --app="$metronome_app" --key="install_dir")/conf/conf.d" } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 3804255..66c7ed6 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,31 +8,28 @@ 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 LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/$app" +ynh_backup "/etc/$app" -ynh_backup --src_path="/var/lib/$app" +ynh_backup "/var/lib/$app" -ynh_backup --src_path="$(_get_metronome_config_dir)/$app.cfg.lua" +ynh_backup "$(_get_metronome_config_dir)/$app.cfg.lua" -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 1b6fb56..b765456 100755 --- a/scripts/install +++ b/scripts/install @@ -19,16 +19,16 @@ fi # INITIALIZE AND STORE SETTINGS #================================================= -shared_secret="$(ynh_string_random 25)" -ynh_app_setting_set --app="$app" --key="shared_secret" --value="$shared_secret" +shared_secret="$(ynh_string_random --length=25)" +ynh_app_setting_set --key="shared_secret" --value="$shared_secret" admin_jid="${admin}@${app}.${domain}" -ynh_app_setting_set --app="$app" --key="admin_jid" --value="$admin_jid" +ynh_app_setting_set --key="admin_jid" --value="$admin_jid" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Setting up the data directory..." +ynh_script_progression "Setting up the data directory..." # Set permissions to app files chown -R _biboumi:_biboumi "/var/lib/$app" @@ -36,45 +36,45 @@ chown -R _biboumi:_biboumi "/var/lib/$app" #================================================= # APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." # Stop the service started by apt install -ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" +ynh_systemctl --service="$app" --action="stop" --log_path="systemd" # Add metronome component metronome_config_dir=$(_get_metronome_config_dir) -ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua" +ynh_config_add --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua" chown metronome:metronome "$metronome_config_dir/$app.cfg.lua" -ynh_systemd_action --service_name="metronome" --action="restart" +ynh_systemctl --service="metronome" --action="restart" # Add biboumi configuration mkdir -p "/etc/$app/" -ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg" +ynh_config_add --template="biboumi.cfg" --destination="/etc/$app/$app.cfg" chown -R _biboumi:_biboumi "/etc/$app/$app.cfg" #================================================= # 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 systemd config systemctl enable "$app.service" --quiet yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) -ynh_use_logrotate -chown -R _biboumi:_biboumi "/var/log/$app" +ynh_config_add_logrotate +#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 _biboumi:_biboumi "/var/log/$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server" #================================================= # 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 7bf9ab5..13ab7a4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,37 +10,37 @@ 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_systemd_action --service_name="$app" --action="stop" --log_path="systemd" +ynh_systemctl --service="$app" --action="stop" --log_path="systemd" systemctl disable "$app.service" --quiet # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." # Remove data directory -ynh_secure_remove --file="/var/lib/$app" +ynh_safe_rm "/var/lib/$app" # Remove a directory securely -ynh_secure_remove --file="/etc/$app" +ynh_safe_rm "/etc/$app" # Remove Metronome component -ynh_secure_remove --file="$(_get_metronome_config_dir)/$app.cfg.lua" -ynh_systemd_action --action=restart --service_name=metronome +ynh_safe_rm "$(_get_metronome_config_dir)/$app.cfg.lua" +ynh_systemctl --action=restart --service=metronome #================================================= # 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 11a6d26..b48266c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression "Validating restoration parameters..." if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)" @@ -20,46 +20,46 @@ fi #================================================= # 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="/var/lib/$app" +ynh_restore "/var/lib/$app" chown -R _biboumi:_biboumi "/var/lib/$app" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression "Restoring various files..." -ynh_restore_file --origin_path="/etc/$app" +ynh_restore "/etc/$app" chown -R _biboumi:_biboumi "/etc/$app" metronome_config_dir=$(_get_metronome_config_dir) -ynh_restore_file --origin_path="$metronome_config_dir/$app.cfg.lua" +ynh_restore "$metronome_config_dir/$app.cfg.lua" chown metronome:metronome "$metronome_config_dir/$app.cfg.lua" -ynh_systemd_action --service_name=metronome --action="restart" +ynh_systemctl --service=metronome --action="restart" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." systemctl enable "$app.service" --quiet yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" -ynh_restore_file --origin_path="/var/log/$app/" -chown -R _biboumi:_biboumi "/var/log/$app" +ynh_restore "/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 _biboumi:_biboumi "/var/log/$app" #================================================= # 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" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server" #================================================= # 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 eaa512f..4f39726 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,14 +10,14 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" +ynh_systemctl --service="$app" --action="stop" --log_path="systemd" #================================================= # CREATE DIRECTORIES #================================================= -ynh_script_progression --message="Setting up the data directory..." +ynh_script_progression "Setting up the data directory..." # Set permissions to app files chown -R _biboumi:_biboumi "/var/lib/$app" @@ -25,40 +25,40 @@ chown -R _biboumi:_biboumi "/var/lib/$app" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating $app's configuration files..." --weight=1 +ynh_script_progression "Updating $app's configuration files..." # Upgrade metronome component metronome_config_dir=$(_get_metronome_config_dir) -ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua" +ynh_config_add --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua" chown metronome:metronome "$metronome_config_dir/$app.cfg.lua" -ynh_systemd_action --service_name=metronome --action="restart" +ynh_systemctl --service=metronome --action="restart" # Upgrade biboumi configuration -ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg" +ynh_config_add --template="biboumi.cfg" --destination="/etc/$app/$app.cfg" chown -R _biboumi:_biboumi "/etc/$app/$app.cfg" #================================================= # 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 systemd config systemctl enable "$app.service" --quiet yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append -chown -R _biboumi:_biboumi "/var/log/$app" +ynh_config_add_logrotate +#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 _biboumi:_biboumi "/var/log/$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"