diff --git a/manifest.toml b/manifest.toml index 2650278..96e1d83 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,11 +18,10 @@ demo = "https://test.mosquitto.org" admindoc = "https://mosquitto.org/documentation/" code = "https://github.com/eclipse/mosquitto" cpe = "cpe:2.3:a:eclipse:mosquitto" -# fund = "???" [integration] yunohost = ">= 11.0.0" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +architectures = "all" multi_instance = false ldap = false sso = false diff --git a/scripts/backup b/scripts/backup index 427e714..030a73e 100755 --- a/scripts/backup +++ b/scripts/backup @@ -33,6 +33,8 @@ ynh_backup --src_path="/etc/mosquitto/passwd" # Backup the config file ynh_backup --src_path="/etc/mosquitto/conf.d/default.conf" +ynh_backup --src_path="/var/log/$app/" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 14c3f3e..a2db82d 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,13 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +# Passwords aren't saved by default +ynh_app_setting_set --app="$app" --key=userpass --value="$userpass" + #================================================= # SPECIFIC SETUP #================================================= @@ -23,21 +30,14 @@ mosquitto_passwd -U "/etc/mosquitto/passwd" ynh_store_file_checksum --file="/etc/mosquitto/passwd" #================================================= -# GENERIC FINALIZATION +# SYSTEM CONFIGURATION #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" +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 @@ -45,7 +45,7 @@ yunohost service add $app --description="Allows MQTT clients to send/receive dat ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" +ynh_systemd_action --service_name="$app" --action="restart" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index d7d6064..6da8cb4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,31 +10,18 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate diff --git a/scripts/restore b/scripts/restore index f24094b..b9f67ac 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,15 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/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 #================================================= @@ -21,26 +30,14 @@ ynh_restore_file --origin_path="/etc/mosquitto/passwd" # Restore the config file ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" +ynh_restore_file --origin_path="/var/log/$app/" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" +ynh_systemd_action --service_name="$app" --action="restart" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index da08d01..c038fef 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,8 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -18,20 +16,18 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" +ynh_systemd_action --service_name="$app" --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -cat /etc/yunohost/apps/$app/settings.yml - # 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" +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 #================================================= @@ -48,28 +44,21 @@ mosquitto_passwd -U "/etc/mosquitto/passwd" ynh_store_file_checksum --file="/etc/mosquitto/passwd" #================================================= -# GENERIC FINALIZATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +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 -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" +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" +ynh_systemd_action --service_name="$app" --action="restart" #================================================= # END OF SCRIPT