1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mosquitto_ynh.git synced 2024-09-03 19:45:54 +02:00

Manifest v2

This commit is contained in:
Salamandar 2023-12-13 00:28:26 +01:00 committed by Félix Piédallu
parent 2314ef2f18
commit 886256212a
10 changed files with 89 additions and 239 deletions

View file

@ -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

View file

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

63
manifest.toml Normal file
View file

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

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
extra_pkg_dependencies="mosquitto"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

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

View file

@ -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
#=================================================

View file

@ -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
#=================================================

13
tests.toml Normal file
View file

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