#!/bin/bash source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression "Stopping $app's systemd service..." ynh_systemctl --service="$app" --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression "Ensuring downward compatibility..." # Transfer and delete the old "password" key if [ -z "${userpass:-}" ]; then userpass="$password" ynh_app_setting_set --key="userpass" --value="$userpass" ynh_app_setting_delete --key="password" fi #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression "Updating configuration..." ynh_config_add --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" 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 "/etc/mosquitto/passwd" # Hard coded username because deb package creates the user chown -R "mosquitto" "/etc/mosquitto" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression "Upgrading system configurations related to $app..." # Use logrotate to manage app-specific logfile(s) 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 "Starting $app's systemd service..." ynh_systemctl --service="$app" --action="restart" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Upgrade of $app completed"