mirror of
https://github.com/YunoHost-Apps/mosquitto_ynh.git
synced 2024-09-03 19:45:54 +02:00
71 lines
2.6 KiB
Bash
Executable file
71 lines
2.6 KiB
Bash
Executable file
#!/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_systemd_action --service_name="$app" --action="stop"
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# 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"
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
ynh_add_config --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"
|
|
mosquitto_passwd -U "/etc/mosquitto/passwd"
|
|
ynh_store_file_checksum --file="/etc/mosquitto/passwd"
|
|
|
|
# Hard coded username because deb package creates the user
|
|
chown -R "mosquitto" "/etc/mosquitto"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --non-append
|
|
|
|
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_systemd_action --service_name="$app" --action="restart"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|