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

Merge pull request #10 from YunoHost-Apps/manifestv2

Manifest v2
This commit is contained in:
Salamandar 2024-01-19 19:23:09 +01:00 committed by GitHub
commit ef3a85051b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 126 additions and 289 deletions

View file

@ -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). [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 **Demo:** https://test.mosquitto.org
## Documentation and resources ## Documentation and resources

View file

@ -19,7 +19,7 @@ Si vous navez 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). [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 **Démo :** https://test.mosquitto.org
## Documentations et ressources ## Documentations et ressources

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

62
manifest.toml Normal file
View file

@ -0,0 +1,62 @@
#: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~ynh2"
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"
[integration]
yunohost = ">= 11.0.0"
architectures = "all"
multi_instance = false
ldap = false
sso = false
disk = "50M"
ram.build = "100M"
ram.runtime = "10M"
[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 # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
extra_pkg_dependencies="mosquitto"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -10,24 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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 # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -51,6 +33,8 @@ ynh_backup --src_path="/etc/mosquitto/passwd"
# Backup the config file # Backup the config file
ynh_backup --src_path="/etc/mosquitto/conf.d/default.conf" ynh_backup --src_path="/etc/mosquitto/conf.d/default.conf"
ynh_backup --src_path="/var/log/$app/"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,50 +10,11 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # INITIALIZE AND STORE SETTINGS
#================================================= #=================================================
# Exit if an error occurs during the execution of the script # Passwords aren't saved by default
ynh_abort_if_errors ynh_app_setting_set --app="$app" --key=userpass --value="$userpass"
#=================================================
# 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 # SPECIFIC SETUP
@ -62,28 +23,24 @@ ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 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" mosquitto_passwd -U "/etc/mosquitto/passwd"
ynh_store_file_checksum --file="/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" # Hard coded username because deb package creates the user
chown -R "mosquitto" "/etc/mosquitto"
#================================================= #=================================================
# GENERIC FINALIZATION # SYSTEM CONFIGURATION
#================================================= #=================================================
# SETUP LOGROTATE ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
#================================================= yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
# 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"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -91,7 +48,7 @@ yunohost service add $app --description="Allows MQTT clients to send/receive dat
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="restart" ynh_systemd_action --service_name="$app" --action="restart"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -10,61 +10,24 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
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
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
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`) # 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 if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # 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 ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate 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 # SPECIFIC REMOVE
#================================================= #=================================================
@ -73,7 +36,7 @@ fi
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app/$app.log" ynh_secure_remove --file="/var/log/$app"
# Remove the passwd file # Remove the passwd file
ynh_secure_remove --file="/etc/mosquitto/passwd" ynh_secure_remove --file="/etc/mosquitto/passwd"

View file

@ -11,63 +11,34 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# Exit if an error occurs during the execution of the script ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_abort_if_errors
#================================================= yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
# 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 # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." --weight=1 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" ynh_restore_file --origin_path="/etc/mosquitto/passwd"
# Restore the config file ynh_restore_file --origin_path="/var/log/$app/"
ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf"
#================================================= # Hard coded username because deb package creates the user
# RESTORE THE LOGROTATE CONFIGURATION chown -R "mosquitto" "/etc/mosquitto"
#================================================= chown -R "mosquitto" "/var/log/$app/"
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"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 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 # GENERIC FINALIZATION

View file

@ -9,45 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -55,19 +16,19 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." 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 # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#================================================= # Transfer and delete the old "password" key
# UPGRADE DEPENDENCIES if [ -z "${userpass:-}" ]; then
#================================================= userpass="$password"
ynh_script_progression --message="Upgrading dependencies..." --weight=10 ynh_app_setting_set --app="$app" --key="userpass" --value="$userpass"
ynh_app_setting_delete --app="$app" --key="password"
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" fi
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -76,36 +37,32 @@ ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 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_delete_file_checksum --file="/etc/mosquitto/passwd"
ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd"
mosquitto_passwd -U "/etc/mosquitto/passwd" mosquitto_passwd -U "/etc/mosquitto/passwd"
ynh_store_file_checksum --file="/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" # Hard coded username because deb package creates the user
chown -R "mosquitto" "/etc/mosquitto"
#================================================= #=================================================
# GENERIC FINALIZATION # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
# SETUP LOGROTATE ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#================================================= yunohost service add "$app" --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
# 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"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 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 # END OF SCRIPT

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"