From 886256212a876ad850e740b3fab953f2a9e8b8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 13 Dec 2023 00:28:26 +0100 Subject: [PATCH 1/9] Manifest v2 --- check_process | 16 ------------ manifest.json | 51 ------------------------------------- manifest.toml | 63 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 3 --- scripts/backup | 18 ------------- scripts/install | 52 +++----------------------------------- scripts/remove | 29 +-------------------- scripts/restore | 27 -------------------- scripts/upgrade | 56 +++++++---------------------------------- tests.toml | 13 ++++++++++ 10 files changed, 89 insertions(+), 239 deletions(-) delete mode 100644 check_process delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 47b83d8..0000000 --- a/check_process +++ /dev/null @@ -1,16 +0,0 @@ -;; Test complet - ; Manifest - username="mosquitto" - userpass="mosquitto" - port="1883" - ; Checks - pkg_linter=1 - setup_nourl=1 - upgrade=1 - # 2.0.12~ynh1 - upgrade=1 from_commit=eb74d6d63a8bc8561d124429c9fa3bdb8f6af7a0 - backup_restore=1 - port_already_use=1 (1883) -;;; Options -Email=grena+mosquitto@grenabox.fr -Notification=yes diff --git a/manifest.json b/manifest.json deleted file mode 100644 index c4b8e52..0000000 --- a/manifest.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "Mosquitto", - "id": "mosquitto", - "packaging_format": 1, - "description": { - "en": "Interconnect your objects and applications with an open source MQTT broker", - "fr": "Interconnecter vos objets et vos applications grâce à un serveur MQTT open source" - }, - "version": "2.0.14~ynh1", - "url": "https://mosquitto.org/", - "upstream": { - "license": "MIT", - "website": "https://mosquitto.org", - "demo": "https://test.mosquitto.org", - "admindoc": "https://mosquitto.org/documentation/", - "code": "https://github.com/eclipse/mosquitto", - "cpe": "cpe:2.3:a:eclipse:mosquitto" - }, - "license": "MIT", - "maintainer": { - "name": "Grena", - "email": "grena+mosquitto@grenabox.fr" - }, - "requirements": { - "yunohost": ">= 11.0.0" - }, - "multi_instance": false, - "services": [], - "arguments": { - "install": [ - { - "name": "username", - "type": "string", - "ask": { - "en": "Set the username for client authentication", - "fr": "Définissez le nom d'utilisateur pour l'authentification du client" - }, - "example": "mosquitto", - "default": "mosquitto" - }, - { - "name": "userpass", - "type": "password", - "ask": { - "en": "Set the password for client authentication", - "fr": "Définissez le mot de passe pour l'authentification du client" - } - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..d438276 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,63 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "mosquitto" +name = "Mosquitto" +description.en = "Interconnect your objects and applications with an open source MQTT broker" +description.fr = "Interconnecter vos objets et vos applications grâce à un serveur MQTT open source" + +version = "2.0.14~ynh1" + +maintainers = ["Grena"] + +[upstream] +license = "MIT" +website = "https://mosquitto.org" +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"] +multi_instance = false +ldap = false +sso = false +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.username] + ask.en = "Set the username for client authentication" + ask.fr = "Définissez le nom d'utilisateur pour l'authentification du client" + type = "string" + example = "mosquitto" + default = "mosquitto" + + [install.userpass] + ask.en = "Set the password for client authentication" + ask.fr = "Définissez le mot de passe pour l'authentification du client" + type = "password" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + + [resources.ports] + main.default = 1883 + main.exposed = "TCP" + + [resources.apt] + packages = "mosquitto" + + [resources.apt.extras.mosquitto] + repo = "deb https://repo.mosquitto.org/debian bullseye main" + key = "http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + packages = ["mosquitto"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 617436e..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -extra_pkg_dependencies="mosquitto" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 10637f0..427e714 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,24 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -port=$(ynh_app_setting_get --app=$app --key=port) -username=$(ynh_app_setting_get --app=$app --key=username) -userpass=$(ynh_app_setting_get --app=$app --key=userpass) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/install b/scripts/install index b9f40a8..14c3f3e 100644 --- a/scripts/install +++ b/scripts/install @@ -9,52 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -username=$YNH_APP_ARG_USERNAME -userpass=$YNH_APP_ARG_USERPASS - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=username --value=$username -ynh_app_setting_set --app=$app --key=userpass --value=$userpass - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=1883) -ynh_app_setting_set --app=$app --key=port --value=$port - -# Open the port -ynh_script_progression --message="Configuring firewall..." --weight=1 -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=20 - -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" - #================================================= # SPECIFIC SETUP #================================================= @@ -62,12 +16,12 @@ ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd" +ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" +ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd" + mosquitto_passwd -U "/etc/mosquitto/passwd" ynh_store_file_checksum --file="/etc/mosquitto/passwd" -ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/remove b/scripts/remove index e0de391..d7d6064 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,15 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -app=$YNH_APP_INSTANCE_NAME - -port=$(ynh_app_setting_get --app=$app --key=port) - #================================================= # STANDARD REMOVE #================================================= @@ -47,24 +38,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=6 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=2 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= @@ -73,7 +46,7 @@ fi ynh_script_progression --message="Removing various files..." --weight=1 # Remove the log files -ynh_secure_remove --file="/var/log/$app/$app.log" +ynh_secure_remove --file="/var/log/$app" # Remove the passwd file ynh_secure_remove --file="/etc/mosquitto/passwd" diff --git a/scripts/restore b/scripts/restore index bbb2a48..f24094b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,33 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -port=$(ynh_app_setting_get --app=$app --key=port) -username=$(ynh_app_setting_get --app=$app --key=username) -userpass=$(ynh_app_setting_get --app=$app --key=userpass) - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=20 - -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" - #================================================= # RESTORE VARIOUS FILES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bb6c716..2a0696b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,45 +9,8 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -port=$(ynh_app_setting_get --app=$app --key=port) -username=$(ynh_app_setting_get --app=$app --key=username) -userpass=$(ynh_app_setting_get --app=$app --key=userpass) - -# Transfer and delete the old "password" key -if [ -z "$userpass" ]; then - ynh_app_setting_set --app=$app --key=userpass --value=$(ynh_app_setting_get --app=$app --key=password) - ynh_app_setting_delete --app=$app --key=password - userpass=$(ynh_app_setting_get --app=$app --key=userpass) -fi - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -62,12 +25,12 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=10 - -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" +# 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 @@ -76,13 +39,12 @@ ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd" +ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" +ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd" + mosquitto_passwd -U "/etc/mosquitto/passwd" ynh_store_file_checksum --file="/etc/mosquitto/passwd" -ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" - - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..a339f15 --- /dev/null +++ b/tests.toml @@ -0,0 +1,13 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + args.username = "mosquitto" + args.userpass = "mosquitto" + + [default.test_upgrade_from.eb74d6d63a8bc8561d124429c9fa3bdb8f6af7a0] + name = "2.0.12~ynh1" + args.username = "mosquitto" + args.userpass = "mosquitto" From 62f4af04fefa8f667bd90cdbe007b040023ce808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 13 Dec 2023 11:38:09 +0100 Subject: [PATCH 2/9] remove fixmes in manifest --- manifest.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index d438276..2650278 100644 --- a/manifest.toml +++ b/manifest.toml @@ -26,9 +26,9 @@ architectures = "all" # FIXME: can be replaced by a list of supported archs usin multi_instance = false ldap = false sso = false -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +disk = "50M" +ram.build = "100M" +ram.runtime = "10M" [install] [install.username] From 8620cdb2c943bba3749ea1baa0533b2978e5318e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 13 Dec 2023 11:38:13 +0100 Subject: [PATCH 3/9] debug --- scripts/upgrade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2a0696b..da08d01 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,8 +25,10 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= 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 +if [ -z "$userpass" ]; then userpass="$password" ynh_app_setting_set --app="$app" --key="userpass" --value="$userpass" ynh_app_setting_delete --app="$app" --key="password" From 371653bc1e9f055430f35b8085c902c7cf59edbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 19 Jan 2024 17:14:28 +0100 Subject: [PATCH 4/9] Cleanup, fix upgrade --- manifest.toml | 3 +-- scripts/backup | 2 ++ scripts/install | 22 +++++++++++----------- scripts/remove | 21 ++++----------------- scripts/restore | 25 +++++++++++-------------- scripts/upgrade | 29 +++++++++-------------------- 6 files changed, 38 insertions(+), 64 deletions(-) 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 From 6138cd181d6e9a082ce12033ca844fb808830432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 19 Jan 2024 17:29:18 +0100 Subject: [PATCH 5/9] Try to pkill user processes --- scripts/remove | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/remove b/scripts/remove index 6da8cb4..90333b3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,9 @@ if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then fi # Remove the dedicated systemd config +# It seems the simple stop is not enough… +ynh_systemd_action --service_name="$app" --action="stop" +pkill -u "$app" || true ynh_remove_systemd_config # Remove the app-specific logrotate config From fe74e56182e492d598bdd8ed2a242da19826021c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 19 Jan 2024 17:34:34 +0100 Subject: [PATCH 6/9] fix upgrade --- scripts/upgrade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c038fef..2a799eb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,8 +38,9 @@ fi ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf" -ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd" +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" From 95ea253f91bb23f8c68e6446c12937e649e2322a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 19 Jan 2024 19:02:10 +0100 Subject: [PATCH 7/9] Fix permissions due to the system user being handled by the deb package too --- scripts/install | 3 +++ scripts/restore | 9 +++++---- scripts/upgrade | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index a2db82d..fe9c6e0 100644 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,9 @@ 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" + #================================================= # SYSTEM CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index b9f67ac..efa60c8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,14 +24,15 @@ yunohost service add "$app" --description="Allows MQTT clients to send/receive d #================================================= ynh_script_progression --message="Restoring various files..." --weight=1 -# Restore the passwd file +ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf" ynh_restore_file --origin_path="/etc/mosquitto/passwd" -# Restore the config file -ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf" - ynh_restore_file --origin_path="/var/log/$app/" +# Hard coded username because deb package creates the user +chown -R "mosquitto" "/etc/mosquitto" +chown -R "mosquitto" "/var/log/$app/" + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2a799eb..516bae8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,6 +44,9 @@ 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 #================================================= From 67e6c4f04cdd6f27f46ed2a8bdaf56a6c5beee71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 19 Jan 2024 19:22:15 +0100 Subject: [PATCH 8/9] Bump manifest.toml rev --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 96e1d83..9cbd3e9 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Mosquitto" description.en = "Interconnect your objects and applications with an open source MQTT broker" description.fr = "Interconnecter vos objets et vos applications grâce à un serveur MQTT open source" -version = "2.0.14~ynh1" +version = "2.0.14~ynh2" maintainers = ["Grena"] From 6f10dd6a9fc62f67f45665e8609144101b2216d2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 19 Jan 2024 18:22:39 +0000 Subject: [PATCH 9/9] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index adc7d68..9b1e2d1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in [Mosquitto](https://mosquitto.org/) gives you interconnect your objects and applications with an open source MQTT broker. Client can publish or subscribe after authentication (username, password). -**Shipped version:** 2.0.14~ynh1 +**Shipped version:** 2.0.14~ynh2 **Demo:** https://test.mosquitto.org ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index e096cd4..58b2916 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po [Mosquitto](https://mosquitto.org/) vous permet d'interconnecter vos objets et applications avec un broker MQTT open source. Le client peut publier ou s'abonner après authentification (nom d'utilisateur, mot de passe). -**Version incluse :** 2.0.14~ynh1 +**Version incluse :** 2.0.14~ynh2 **Démo :** https://test.mosquitto.org ## Documentations et ressources