mirror of
https://github.com/YunoHost-Apps/mosquitto_ynh.git
synced 2024-09-03 19:45:54 +02:00
Apply last example_ynh
This commit is contained in:
parent
74185f9e1f
commit
b8b3bbe0ff
18 changed files with 110 additions and 168 deletions
|
@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide
|
||||||
1. *Read this whole template first.*
|
1. *Read this whole template first.*
|
||||||
2. *Determine if you are on the right place:*
|
2. *Determine if you are on the right place:*
|
||||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||||
- *Otherwise, the issue may be due to mosquitto itself. Refer to its documentation or repository for help.*
|
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||||
- *When in doubt, post here and we will figure it out together.*
|
- *When in doubt, post here and we will figure it out together.*
|
||||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
---
|
---
|
||||||
|
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
|
||||||
|
|
||||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
```sh
|
```sh
|
||||||
sudo yunohost app install mosquitto
|
sudo yunohost app install the_app
|
||||||
```
|
```
|
||||||
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||||
- *If the error occurs in your browser, explain what you did:*
|
- *If the error occurs in your browser, explain what you did:*
|
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
- *Description of why you made this PR*
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
- *And how do you fix that problem*
|
||||||
|
|
||||||
|
## PR Status
|
||||||
|
|
||||||
|
- [ ] Code finished and ready to be reviewed/tested
|
||||||
|
- [ ] The fix/enhancement were manually tested (if applicable)
|
||||||
|
|
||||||
|
## Automatic tests
|
||||||
|
|
||||||
|
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
|
|
@ -7,7 +7,10 @@
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_nourl=1
|
setup_nourl=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
# 1.5.7~ynh1
|
||||||
upgrade=1 from_commit=3423395180264623342ee41946d10f30cd38e471
|
upgrade=1 from_commit=3423395180264623342ee41946d10f30cd38e471
|
||||||
|
# 2.0.8~ynh1
|
||||||
|
upgrade=1 from_commit=74185f9e1fb58a91271cfc24630029da662b6111
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
port_already_use=1 (1883)
|
port_already_use=1 (1883)
|
||||||
;;; Options
|
;;; Options
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
listener __PORT__
|
listener __PORT__
|
||||||
|
|
||||||
allow_anonymous false
|
allow_anonymous false
|
||||||
password_file __PASSWORD_FILE__
|
password_file /etc/mosquitto/passwd
|
||||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
1
doc/DESCRIPTION.md
Normal file
1
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[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).
|
1
doc/DESCRIPTION_fr.md
Normal file
1
doc/DESCRIPTION_fr.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[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).
|
3
doc/DISCLAIMER.md
Normal file
3
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
- [ ] Add MQTTS (MQTT with TLS)
|
3
doc/DISCLAIMER_fr.md
Normal file
3
doc/DISCLAIMER_fr.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## A faire
|
||||||
|
|
||||||
|
- [ ] Ajouter MQTTS (MQTT avec TLS)
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
|
@ -8,18 +8,26 @@
|
||||||
},
|
},
|
||||||
"version": "2.0.8~ynh1",
|
"version": "2.0.8~ynh1",
|
||||||
"url": "https://mosquitto.org/",
|
"url": "https://mosquitto.org/",
|
||||||
|
"upstream": {
|
||||||
|
"license": "MIT",
|
||||||
|
"website": "https://mosquitto.org",
|
||||||
|
"demo": "https://demo.example.com",
|
||||||
|
"admindoc": "https://mosquitto.org/documentation/",
|
||||||
|
"userdoc": "https://yunohost.org/apps",
|
||||||
|
"code": "https://some.forge.com/example/example"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Grena",
|
"name": "Grena",
|
||||||
"email": "grena+mosquitto@grenabox.fr"
|
"email": "grena+mosquitto@grenabox.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.1.0"
|
"yunohost": ">= 4.3.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [],
|
"services": [],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install": [
|
||||||
{
|
{
|
||||||
"name": "username",
|
"name": "username",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -42,4 +50,3 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
## Problem
|
|
||||||
- *Description of why you made this PR*
|
|
||||||
|
|
||||||
## Solution
|
|
||||||
- *And how do you fix that problem*
|
|
||||||
|
|
||||||
## PR Status
|
|
||||||
- [ ] Code finished.
|
|
||||||
- [ ] Tested with Package_check.
|
|
||||||
- [ ] Fix or enhancement tested.
|
|
||||||
- [ ] Upgrade from last version tested.
|
|
||||||
- [ ] Can be reviewed and tested.
|
|
||||||
|
|
||||||
## Package_check results
|
|
||||||
---
|
|
||||||
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
|
|
|
@ -4,16 +4,8 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# files used by the app
|
|
||||||
password_file="/etc/mosquitto/passwd"
|
|
||||||
config_file="/etc/mosquitto/conf.d/default.conf"
|
|
||||||
|
|
||||||
# extra repository used by the app
|
|
||||||
extra_repo="deb https://repo.mosquitto.org/debian buster main"
|
|
||||||
extra_repo_key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key"
|
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="mosquitto"
|
extra_pkg_dependencies="mosquitto"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -33,13 +33,6 @@ password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
|
||||||
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -53,14 +46,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Backup the passwd file
|
# Backup the passwd file
|
||||||
ynh_backup --src_path="$password_file"
|
ynh_backup --src_path="/etc/mosquitto/passwd"
|
||||||
|
|
||||||
# Backup the config file
|
# Backup the config file
|
||||||
ynh_backup --src_path="$config_file"
|
ynh_backup --src_path="/etc/mosquitto/conf.d/default.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ ynh_abort_if_errors
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
username=$YNH_APP_ARG_USERNAME
|
username=$YNH_APP_ARG_USERNAME
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -53,38 +53,19 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=20
|
ynh_script_progression --message="Installing dependencies..." --weight=20
|
||||||
|
|
||||||
ynh_install_extra_app_dependencies --repo="$extra_repo" --package="$pkg_dependencies" --key="$extra_repo_key" --name="$app"
|
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE MOSQUITTO
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Mosquitto Password..." --weight=1
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
|
|
||||||
cp ../conf/passwd "$password_file"
|
ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd"
|
||||||
|
mosquitto_passwd -U "/etc/mosquitto/passwd"
|
||||||
|
|
||||||
ynh_replace_string --match_string="__USERNAME__" --replace_string="$username" --target_file="$password_file"
|
ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf"
|
||||||
ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$password_file"
|
|
||||||
mosquitto_passwd -U "$password_file"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$password_file"
|
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring Mosquitto..." --weight=1
|
|
||||||
|
|
||||||
cp ../conf/mosquitto.conf "$config_file"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
|
||||||
ynh_replace_string --match_string="__PASSWORD_FILE__" --replace_string="$password_file" --target_file="$config_file"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$config_file"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTART SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restarting systemd service..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action=restart
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -104,16 +85,15 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated Fail2Ban config
|
# Start a systemd service
|
||||||
#ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --ports="$port" --failregex="Regex to match into the log for a failed login"
|
ynh_systemd_action --service_name=$app --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
username=$(ynh_app_setting_get --app=$app --key=username)
|
|
||||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -41,14 +39,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=6
|
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -57,6 +47,14 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
|
||||||
# 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
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -67,14 +65,6 @@ then
|
||||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing Fail2ban configuration..." --weight=1
|
|
||||||
|
|
||||||
# Remove the dedicated Fail2Ban config
|
|
||||||
#ynh_remove_fail2ban_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,14 +76,13 @@ ynh_script_progression --message="Removing various files..." --weight=1
|
||||||
ynh_secure_remove --file="/var/log/$app/$app.log"
|
ynh_secure_remove --file="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Remove the passwd file
|
# Remove the passwd file
|
||||||
ynh_secure_remove --file="$password_file"
|
ynh_secure_remove --file="/etc/mosquitto/passwd"
|
||||||
|
|
||||||
# Remove the config file
|
# Remove the config file
|
||||||
ynh_secure_remove --file="$config_file"
|
ynh_secure_remove --file="/etc/mosquitto/conf.d/default.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
||||||
|
|
|
@ -28,17 +28,6 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
username=$(ynh_app_setting_get --app=$app --key=username)
|
username=$(ynh_app_setting_get --app=$app --key=username)
|
||||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
|
|
||||||
|
|
||||||
#ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
|
||||||
#ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
#ynh_systemd_action --action=restart --service_name=fail2ban
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -46,7 +35,25 @@ ynh_script_progression --message="Restoring the Fail2Ban configuration..." --wei
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
|
||||||
|
|
||||||
ynh_install_extra_app_dependencies --repo="$extra_repo" --package="$pkg_dependencies" --key="$extra_repo_key" --name="$app"
|
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
||||||
|
|
||||||
|
# Restore the passwd file
|
||||||
|
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
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
@ -56,33 +63,16 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the Mosquitto configuration..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Restore the passwd file
|
ynh_systemd_action --service_name=$app --action="restart"
|
||||||
ynh_restore_file --origin_path="$password_file"
|
|
||||||
|
|
||||||
# Restore the config file
|
|
||||||
ynh_restore_file --origin_path="$config_file"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTART SYSTEMD SERVICE
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restarting systemd service..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action=restart
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the log rotation..." --weight=1
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,10 @@ password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking version..."
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -47,51 +43,37 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=10
|
ynh_script_progression --message="Upgrading dependencies..." --weight=10
|
||||||
|
|
||||||
ynh_install_extra_app_dependencies --repo="$extra_repo" --package="$pkg_dependencies" --key="$extra_repo_key" --name="$app"
|
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Mosquitto Password..." --weight=1
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different.
|
ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd"
|
||||||
ynh_backup_if_checksum_is_different --file="$password_file"
|
mosquitto_passwd -U "/etc/mosquitto/passwd"
|
||||||
|
|
||||||
cp ../conf/passwd "$password_file"
|
ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf"
|
||||||
|
|
||||||
ynh_replace_string --match_string="__USERNAME__" --replace_string="$username" --target_file="$password_file"
|
|
||||||
ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$password_file"
|
|
||||||
mosquitto_passwd -U "$password_file"
|
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum --file="$password_file"
|
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring Mosquitto..." --weight=1
|
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different.
|
|
||||||
ynh_backup_if_checksum_is_different --file="$config_file"
|
|
||||||
|
|
||||||
cp ../conf/mosquitto.conf "$config_file"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
|
||||||
ynh_replace_string --match_string="__PASSWORD_FILE__" --replace_string="$password_file" --target_file="$config_file"
|
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum --file="$config_file"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTART SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restarting systemd service..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action=restart
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -111,12 +93,11 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE FAIL2BAN
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated Fail2Ban config
|
ynh_systemd_action --service_name=$app --action="restart"
|
||||||
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Reference in a new issue