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

108 lines
3.9 KiB
Text
Raw Normal View History

2017-10-26 13:01:33 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Loading installation settings..." --weight=1
2017-10-26 13:01:33 +02:00
app=$YNH_APP_INSTANCE_NAME
2021-02-13 18:14:54 +01:00
port=$(ynh_app_setting_get --app=$app --key=port)
username=$(ynh_app_setting_get --app=$app --key=username)
password=$(ynh_app_setting_get --app=$app --key=password)
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# CHECK VERSION
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
ynh_script_progression --message="Checking version..."
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
upgrade_type=$(ynh_check_app_version_changed)
2017-10-26 13:01:33 +02:00
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
2017-10-26 13:01:33 +02:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
2021-02-13 18:14:54 +01:00
# Restore it if the upgrade fails
2017-10-26 13:01:33 +02:00
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
2021-02-13 18:14:54 +01:00
# STANDARD UPGRADE STEPS
2022-06-20 01:41:47 +02:00
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2021-02-13 18:14:54 +01:00
#=================================================
# UPGRADE DEPENDENCIES
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Upgrading dependencies..." --weight=10
2017-10-26 13:01:33 +02:00
2023-04-10 18:24:41 +02:00
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian bullseye main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# SPECIFIC UPGRADE
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
# UPDATE A CONFIG FILE
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
ynh_script_progression --message="Updating a configuration file..." --weight=1
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd"
mosquitto_passwd -U "/etc/mosquitto/passwd"
2023-04-21 21:28:08 +02:00
ynh_store_file_checksum --file="/etc/mosquitto/passwd"
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf"
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
# START SYSTEMD SERVICE
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
ynh_systemd_action --service_name=$app --action="restart"
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# END OF SCRIPT
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last