1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/domoticz_ynh.git synced 2024-09-03 18:26:17 +02:00

convert to v2 w/o mosquitto

This commit is contained in:
Krakinou 2023-07-21 23:19:13 +02:00
parent 8df1b25003
commit 007a21e138
14 changed files with 85 additions and 210 deletions

View file

@ -2,54 +2,16 @@
### Broker MQTT Mosquitto
A l'installation, un broker [MQTT](https://fr.wikipedia.org/wiki/MQTT), [Mosquitto](https://mosquitto.org/), est installé en même temps que Domoticz.
Ce broker nécessite un domaine ou un sous-domaine particulier pour fonctionner (ex : mqtt.your.domain.tld) : il est nécessaire de créer ce domaine auparavant.
Vous pouvez install le broker [MQTT](https://fr.wikipedia.org/wiki/MQTT) [Mosquitto](https://github.com/YunoHost-Apps/mosquitto_ynh) simultanément à domoticz.
#### Ajout dans domoticz
Pour pouvoir l'utiliser, vous devez paramétrer la communication avec entre domoticz et le broker en suivant la [documentation de domoticz](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto) dans la partie *Add hardware "MQTT Client Gateway"*
Les users et mot de passe du broker sont automatiquement générés lors de l'installation. Vous pouvez les récupérer avec
````
sudo yunohost app setting domoticz mqtt_user
sudo yunohost app setting domoticz mqtt_pwd
````
#### Publier/souscrire
Par défaut, mosquitto va écouter sur 2 ports:
- Le 1883 sur localhost en protocole mqtt
- Le 8883 en protocole websocket. Nginx redirige le port 443 externe vers ce port en interne.
Pour publier/souscrire sur un topic depuis l'exterieur, vous devez donc utiliser un programme supportant le protocole websocket (ex : la bibliothèque python paho).:
#### Mosquitto_pub et mosquitto_sub
Ces deux programmes ne supportent pas le protocole websocket mais uniquement le mqtt : le paramétrage de base ne vous autorise donc pas à les utiliser pour communiquer depuis un client externe.
Si vous les utilisez directement depuis votre serveur, ce genre de syntaxe devrait marcher:
````
mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }'
````
De la même manière:c
````
mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/out'
````
Si vous souhaitez ouvrir le protocole mqtt depuis l'extérieur afin de pouvoir les utiliser depuis un autre serveur, il vous faudra:
- ouvrir le port 1883 sur le firewall Yunohost (**Attention, risque de sécurité**)
- autoriser les adresses IP souhaitées dans la configuration de mosquitto pour ce listener
- paramétrer le tls dans la configuration de mosquitto en donnant accès au crt.pem et key.pem de votre domaine mqtt en les paramétrant respectivement avec les variables certfile et keyfile. **Ceci est obligatoire pour sécuriser la connexion.**
#### Mise à jour depuis les versions n'ayant pas mosquittoo
Si vous êtes sur le package 2020.2~ynh3 ou inférieur, mosquitto n'est pas installé par défaut.
De même si vous avez choisi de ne pas indiquer de domaine pour mosquitto lors de l'installation initiale.
Pour pouvoir l'installer après coup, faites les actions suivantes:
1. créez un domaine ou sous-domaine pour recevoir les informations (par exemple : 'mqtt.your.domain.tld')
2. connecter vous en ligne de commande à votre serveur
3. taper la commande suivante : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld`
4. Procédez à la mise à jour.
Si vous êtes déjà sur la dernière version, utiliser la commmande suivante : `yunohost app upgrade domoticz --force`
#### Migration depuis la version 2020.2~ynh7
Avant la version 2023.2~ynh1, domoticz_ynh pouvait intégrer directement le broker mosquitto lors de son installation. Cette option n'est plus maintenu car trop complexe.
Pour migrer vers depuis une installation de mosquitto "intradomoticz" vers le package officiel de mosquitto pour domoticz, merci de consulter cette [documentation]
### Senseurs, langue et ce genre de choses
Toute la configuration de l'application a lieu dans l'application elle même

View file

@ -1,11 +1,6 @@
### Première connexion
L'utilisateur *admin* et le mot de passe *domoticz* vous permettront d'accéder au système. Il est bien évidemment recommandé de les modifier immédiatement
Les users et mot de passe du broker mosquitto sont automatiquement générés lors de l'installation. Vous pouvez les récupérer avec
````
sudo yunohost app setting domoticz mqtt_user
sudo yunohost app setting domoticz mqtt_pwd
````
### recommandations

View file

@ -1,12 +1,6 @@
### Initial access
User *admin* with password *domoticz* allow you to access the system. Of course, you should change them immediately.
User and password for mosquitto broker are automatically generated during installation, you may retrieve them with
````
sudo yunohost app setting domoticz mqtt_user
sudo yunohost app setting domoticz mqtt_pwd
````
### recommandation

View file

@ -1,8 +0,0 @@
## Mosquitto Broker
During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), may be installed at the same time as Domoticz. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed.
This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite
## Installed Version
For now, domoticz project does not (yet) provide compiled binaries for each release. So, the installed release is a precompiled version from a [project fork](https://github.com/Krakinou/domoticz_build_on_arch). The source code is exactly the same as the original version.

View file

@ -1,9 +0,0 @@
## Broker MQTT Mosquitto
A l'installation, un broker [MQTT](https://fr.wikipedia.org/wiki/MQTT), [Mosquitto](https://mosquitto.org/), peut être installé en même temps que Domoticz. Il est optionnel et si vous indiquez lors de l'installation le même domaine que le domaine principal, il ne sera pas installé.
Ce broker nécessite un domaine ou un sous-domaine particulier pour fonctionner (ex : mqtt.your.domain.tld) : il est nécessaire de créer ce domaine auparavant.
## Version installée
Actuellement, le projet domoticz ne fournit pas (encore) ses sources compilées par version. La version installée est donc une version compilée sur un [fork du projet](https://github.com/Krakinou/domoticz_build_on_arch). Le code source est celui de la version correspondante de domoticz.

View file

@ -0,0 +1,4 @@
###Warning###
Starting with 2023.2~ynh1, the integrated mosquitto server into the domoticz_ynh package will not be maintained anymore.
This is due to numerous reasons, the main one being that it render the package overcomplicated while an external package is also available.
You're encouraged to move to the [mosquitto package](https://github.com/YunoHost-Apps/mosquitto_ynh), instruction to doing so being available in the domoticz_ynh documentation.

0
doc/mosquitto.md Normal file
View file

View file

@ -5,7 +5,7 @@ name = "Domoticz"
description.en = "Home automation system that lets you monitor and configure miscellaneous devices"
description.fr = "Logiciel de domotique qui vous permet de configurer un grand nombre d'appareils"
version = "2023.1~ynh2"
version = "2023.2~ynh1"
maintainers = ["Krakinou"]
@ -37,36 +37,26 @@ ram.runtime = "50M"
default = "/domoticz"
[install.init_main_permission]
help.fr = "Attention, cette application n'a pas de gestion d'utilisateur par défaut, si vous la mettez public, n'importe qui y aura accès!"
help.en = "Beware, there is no user management by default. If it's set as public, anyone will have access!"
type = "group"
default = "all_users"
[install.mqtt_domain]
ask.fr = "Domaine MQTT"
ask.en = "MQTT domain"
help.fr = "Domaine pour le serveur MQTT. Remettez le domaine principal si vous ne souhaitez pas l'utiliser. Lire la documentation pour plus d'informations"
help.en = "MQTT server domain. Set the main domain if you don't wish to use it. See the doc for more info"
type = "domain"
optional = true
[resources]
[resources.sources.main]
arm64.url = "https://github.com/Krakinou/domoticz_build_on_arch/releases/download/2023.1/domoticz_linux_2023.1_aarch64.tgz"
arm64.sha256 = "e268e298fdd3d165840e0174b22b6c6b6ef06f4c7d4ab596f3bd6e984cda1b15"
armhf.url = "https://github.com/Krakinou/domoticz_build_on_arch/releases/download/2023.1/domoticz_linux_2023.1_armhf.tgz"
armhf.sha256 = "a51f2a2b6238a36ecc4f41d676fc2448313373ab181dd215630260b8230449db"
amd64.url = "https://github.com/Krakinou/domoticz_build_on_arch/releases/download/2023.1/domoticz_linux_2023.1_x86_64.tgz"
amd64.sha256 = "b88e82af38385d33d78d3dbb034f57ac429855e8dcb2da6c7ee17c7c71ba235f"
arm64.url = "https://github.com/domoticz/domoticz/releases/download/2023.2/domoticz_linux_2023.2_aarch64.tgz"
arm64.sha256 = "b8a475e02ba42a9d7fd4d941b66c6f023cbda910193d471b0a50339152c15969"
armhf.url = "https://github.com/domoticz/domoticz/releases/download/2023.2/domoticz_linux_2023.2_armhf.tgz"
armhf.sha256 = "90cf6192caaac73471449fa096bde6f02c43e80d349ae149874e4cdbb6e033a2"
amd64.url = "https://github.com/domoticz/domoticz/releases/download/2023.2/domoticz_linux_2023.2_x86_64.tgz"
amd64.sha256 = "936b25ca9791b595914bc67993205ce7fb8375c11ac7b03e7efc8682a93461cc"
format="tar.gz"
in_subdir=false
extract=true
autoupdate.strategy = "latest_github_release"
autoupdate.asset.arm64 = "*_aarch64.tgz"
autoupdate.asset.amd64 = "*_x86_64.tgz"
autoupdate.asset.armhf = "*_armhf.tgz"
autoupdate.asset.arm64 = ".*_aarch64.tgz"
autoupdate.asset.amd64 = ".*_x86_64.tgz"
autoupdate.asset.armhf = ".*_armhf.tgz"
[resources.system_user]
@ -75,18 +65,15 @@ ram.runtime = "50M"
[resources.permissions]
main.url = "/"
api.url = "/_api/__APP_"
api.show_title = false
api.url = "/_api/__APP__"
api.show_tile = false
api.allowed = "visitors"
[resources.ports]
main.default = 8080
#to be checked if it can become conditionnal
#ports will always be provisionned... don't know if it's an issue...
mqtt.default = 1883
mqtt_websocket.default = 8883
[resources.apt]
packages = "libudev-dev, python3-dev, libcurl4, libusb-0.1-4"
packages_from_raw_bash = '''if [ "$mqtt_domain" != "$domain" ]; then echo mosquitto mosquitto-clients; fi'''
# to be deleted in next version
packages_from_raw_bash = '''if [ "$mosquitto" = 1 ]; then echo mosquitto mosquitto-clients; fi'''

View file

@ -10,6 +10,18 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#from 2023.1~ynh1
#End of support for mosquitto. However, we still keep trace of if it was installed in order to be able to back it up and remove it correctly
mosquitto=$(ynh_app_setting_get --app=$app --key=mosquitto)
if [[ -z "${mosquitto+x}" ]]; then
if [[ "$mqtt_domain"="$domain" ]]; then
ynh_app_setting_set --app="$app" --key=mosquitto --value=0
else
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
ynh_app_setting_set --app="$app" --key=mosquitto --value=1
fi
fi
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -27,7 +39,8 @@ ynh_backup --src_path="$install_dir"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/api_"$app".conf"
[[ "$domain" != "$mqtt_domain" ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
[[ "$mosquitto" = 1 ]] && ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
[[ "$mosquitto" = 1 ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
#=================================================
# SPECIFIC BACKUP
@ -54,7 +67,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# BACKUP VARIOUS FILES
#=================================================
[[ "$domain" != "$mqtt_domain" ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
[[ "$mosquitto" = 1 ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"

View file

@ -34,6 +34,7 @@ else
fi
ynh_app_setting_set --app="$app" --key=api_path --value="$api_path"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -70,34 +71,11 @@ chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app":"$app" "$install_dir"
#=================================================
# SET MOSQUITTO SETTINGS
#=================================================
if [ "$domain" != "$mqtt_domain" ]; then
ynh_script_progression --message="Setting up mosquitto..." --weight=5
#Setting up conf file for access
ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/etc/mosquitto/conf.d/"$app"_mosquitto.conf"
chmod 644 /etc/mosquitto/conf.d/"$app"_mosquitto.conf
#Setting up user&pwd for mqtt access
ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8)
ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random)
echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials"
mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials"
ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
[[ "$domain" != "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
#Set Hook for nginx domain
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
@ -128,7 +106,6 @@ chown -R domoticz: /var/log/"$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
[[ "$domain" != "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@ -136,8 +113,6 @@ ynh_use_logrotate
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
#=================================================
# START SYSTEMD SERVICE
@ -147,9 +122,6 @@ ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start"
#Restarting mosquitto to take changes into account
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
#=================================================
# SETUP FAIL2BAN
#=================================================
@ -172,12 +144,6 @@ ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed logi
#=================================================
ynh_script_progression --message="Configuring permissions..."
#API & MQTT should stay publicly accessible.
#ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true"
[[ "$domain" != "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,13 +9,25 @@
source _common.sh
source /usr/share/yunohost/helpers
#from 2023.1~ynh1
#End of support for mosquitto. However, we still keep trace of if it was installed in order to be able to back it up and remove it correctly
mosquitto=$(ynh_app_setting_get --app=$app --key=mosquitto)
if [[ -z "${mosquitto+x}" ]]; then
if [[ "$mqtt_domain"="$domain" ]]; then
ynh_app_setting_set --app="$app" --key=mosquitto --value=0
else
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
ynh_app_setting_set --app="$app" --key=mosquitto --value=1
fi
fi
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
if [ "$domain" != "$mqtt_domain" ]; then
if [ "$mosquitto" = 1 ]; then
ynh_script_progression --message="Removing system configurations related to Mosquitto..." --weight=1
yunohost service remove mosquitto
ynh_secure_remove --file="/etc/mosquitto/conf.d"
@ -23,8 +35,6 @@ if [ "$domain" != "$mqtt_domain" ]; then
ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
yunohost tools regen-conf postfix
ynh_secure_remove --file="/var/log/mosquitto"
fi
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1

View file

@ -17,6 +17,17 @@ then
current_mach="armv7l"
fi
#from 2023.1~ynh1
#End of support for mosquitto. However, we still keep trace of if it was installed in order to be able to back it up and remove it correctly
mosquitto=$(ynh_app_setting_get --app=$app --key=mosquitto)
if [[ -z "${mosquitto+x}" ]]; then
if [[ "$mqtt_domain"="$domain" ]]; then
ynh_app_setting_set --app="$app" --key=mosquitto --value=0
else
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
ynh_app_setting_set --app="$app" --key=mosquitto --value=1
fi
fi
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -71,8 +82,9 @@ chown -R "$app":"$app" "$install_dir"
#=================================================
# SET MOSQUITTO SETTINGS
#=================================================
if [ "$domain" != "$mqtt_domain" ]; then
if [ "$mosquitto" = 1 ]; then
ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
ynh_restore_file --origin_path="/etc/mosquitto/conf.d" --not_mandatory
fi
@ -90,7 +102,7 @@ systemctl enable "$app".service --quiet
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
[[ "$mosquitto" = 1 ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
#=================================================
@ -101,7 +113,7 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#Restarting mosquitto to take changes into account
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
[[ "$mosquitto" = 1 ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION

View file

@ -9,6 +9,18 @@
source _common.sh
source /usr/share/yunohost/helpers
#from 2023.1~ynh1
#End of support for mosquitto. However, we still keep trace of if it was installed in order to be able to back it up and remove it correctly
mosquitto=$(ynh_app_setting_get --app=$app --key=mosquitto)
if [[ -z "${mosquitto+x}" ]]; then
if [[ "$mqtt_domain"="$domain" ]]; then
ynh_app_setting_set --app="$app" --key=mosquitto --value=0
else
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
ynh_app_setting_set --app="$app" --key=mosquitto --value=1
fi
fi
#=================================================
# CHECK VERSION
#=================================================
@ -58,22 +70,6 @@ if [ -z "$api_path" ]; then
ynh_app_setting_set --app="$app" --key=api_path --value="$api_path"
fi
#Previous version did not have settings stored and
#variable may not be bound.
if [[ -z "${mqtt_domain+x}" ]]; then
mqtt_domain="$domain"
ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain"
fi
# Create the permission "domoticz_MQTT" only if it doesn't exist.
if [ "$domain" != "$mqtt_domain" ]; then
if ! ynh_permission_exists --permission="domoticz_MQTT"
then
# API Authorization with dedicated URL
ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true"
fi
fi
#remove unwanted log folder
if [ -d "/var/log/$app/$app" ]; then
ynh_secure_remove "/var/log/$app/$app"
@ -114,34 +110,12 @@ chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app":"$app" "$install_dir"
#=================================================
# SET MOSQUITTO SETTINGS
#=================================================
if [ "$domain" != "$mqtt_domain" ]; then
ynh_script_progression --message="Setting up mosquitto..." --weight=5
#Setting up conf file for access
if [ ! -f "/etc/mosquitto/conf.d/"$app"_mosquitto.conf" ]
then
ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/etc/mosquitto/conf.d/"$app"_mosquitto.conf"
chmod 644 /etc/mosquitto/conf.d/"$app"_mosquitto.conf
#Setting up user&pwd for mqtt access
ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8)
ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random)
echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials"
mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials"
ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app"
fi
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
[[ "$domain" != "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
[[ "$mosquitto" = 1 ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
#Set Hook for nginx domain
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
@ -177,7 +151,6 @@ chown -R domoticz: /var/log/"$app"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app" --non-append
[[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto"
#=================================================
# SETUP FAIL2BAN
@ -202,8 +175,6 @@ ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed logi
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
#=================================================
# START SYSTEMD SERVICE
@ -212,9 +183,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name="$app" --action="start"
#Restarting mosquitto to take changes from /etc/mosquitto/conf.d/*.conf into account
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -2,12 +2,11 @@ test_format = 1.0
#without Mosquitto
[default]
args.mqtt_domain="sub.domain.tld"
test_upgrade_from.27311ad.name = "2022.2"
test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
# exclude = ["package_linter", "install.root", "install.subdir", "install.private", "install.multi", "backup_restore", "upgrade", "upgrade.27311ad", "change_url"]
# exclude = ["package_linter", "install.root", "install.private", "install.multi", "backup_restore", "upgrade", "upgrade.27311ad", "change_url"]
[With_Mosquitto_upgrade_with_mosquitto]
preinstall = """
@ -15,30 +14,12 @@ test_format = 1.0
yunohost domain add mqtt.domain.tld
"""
args.mqtt_domain="mqtt.domain.tld"
exclude = ["package_linter"]
test_upgrade_from.27311ad.name = "2022.2 with mosquitto"
test_upgrade_from.27311ad.args.mqtt_domain="mqtt.domain.tld"
[Without_Mosquitto_upgrade_with_mosquitto]
# preinstall = """
# set -euxo pipefail
# yunohost domain add mqtt.domain.tld
# """
preupgrade = """
set -euxo pipefail
yunohost domain add mqtt.domain.tld
yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
"""
args.mqtt_domain="sub.domain.tld"
only = ["upgrade","upgrade.27311ad"]
# exclude = ["package_linter", "install.root", "install.subdir", "install.private", "install.multi", "backup_restore", "change_url"]
test_upgrade_from.27311ad.name = "2022.2 without mosquitto"
test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
exclude = ["package_linter", "install.root", "install.subdir", "install.private", "install.multi", "backup_restore", "upgrade", "change_url"]
test_upgrade_from.27311ad.name = "2022.2 with mosquitto"
test_upgrade_from.27311ad.args.mqtt_domain="mqtt.domain.tld"