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] 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"