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

Cleanup, fix upgrade

This commit is contained in:
Salamandar 2024-01-19 17:14:28 +01:00
parent 8620cdb2c9
commit 371653bc1e
6 changed files with 38 additions and 64 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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