1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mosquitto_ynh.git synced 2024-09-03 19:45:54 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 01:07:59 +02:00 committed by Alexandre Aubin
parent ff6455717a
commit 8693bbb6b7
7 changed files with 53 additions and 103 deletions

View file

@ -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

View file

@ -1,17 +1,5 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

View file

@ -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)."

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"