mirror of
https://github.com/YunoHost-Apps/domoticz_ynh.git
synced 2024-09-03 18:26:17 +02:00
Merge pull request #7 from YunoHost-Apps/mqtt-mosquitto
Mqtt broker mosquitto
This commit is contained in:
commit
21c8a6c3d0
18 changed files with 647 additions and 315 deletions
127
README.md
127
README.md
|
@ -1,39 +1,77 @@
|
|||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
# Domoticz for YunoHost
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg)
|
||||
[![Install domoticz with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=domoticz)
|
||||
[![Integration level](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Working status](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg)
|
||||
[![Install Domoticz with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=domoticz)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allows you to install domoticz quickly and simply on a YunoHost server.
|
||||
> *This package allows you to install Domoticz quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
|
||||
Very light weight open sources home automation system that lets you monitor and configure miscellaneous devices
|
||||
|
||||
**Shipped version:** 2020.2~ynh4
|
||||
## Disclaimers / important information
|
||||
|
||||
Domoticz is a Home Automation system design to control various devices and receive input from various sensors.
|
||||
For example this system can be used with:
|
||||
|
||||
-Light switches
|
||||
|
||||
-Door sensors
|
||||
|
||||
-Doorbells
|
||||
|
||||
-Security devices
|
||||
|
||||
-Weather sensors like: UV/Rain/Wind Meters
|
||||
|
||||
-Temperature Sensors
|
||||
|
||||
-Pulse Meters
|
||||
|
||||
-Voltage / AD Meters
|
||||
|
||||
-And more ...
|
||||
* Light switches
|
||||
* Door sensors
|
||||
* Doorbells
|
||||
* Security devices
|
||||
* Weather sensors like: UV/Rain/Wind Meters
|
||||
* Temperature Sensors
|
||||
* Pulse Meters
|
||||
* Voltage / AD Meters
|
||||
* And more ...
|
||||
|
||||
|
||||
**Shipped version:** Always the last stable one. The last compiled version is retrieved from [this directory](https://releases.domoticz.com/releases/?dir=./beta)
|
||||
Once installed, **updates from the uptream app are managed from within the app.**. Yunohost upgrade script will only upgrade the Yunohost package.
|
||||
**Shipped version:** Always the last stable one. The last compiled version is retrieved from [this directory](https://releases.domoticz.com/releases/?dir=./beta) during install.
|
||||
Once installed, **updates from the uptream app are managed from within the app**. Yunohost upgrade script will only upgrade the Yunohost package.
|
||||
|
||||
The MQTT broker mosquitto is integrated into the package. It requires its own domain or subdomain. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Broker Mosquitto
|
||||
|
||||
During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), is installed at the same time as Domoticz. The installed version is the one from the official project repo and not from Debian ones.
|
||||
This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite
|
||||
|
||||
#### Use
|
||||
|
||||
To use mosquitto, you need to customize the communication between domoticz and the broker by following the [domoticz documentation](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto), part *Add hardware "MQTT Client Gateway"*.
|
||||
User and password are automatically generated during installation, you may retrieve them with
|
||||
````
|
||||
sudo yunohost app setting domoticz mqtt_user
|
||||
sudo yunohost app setting domoticz mqtt_pwd
|
||||
````
|
||||
You can then publish on a device on domoticz with following syntax:
|
||||
````
|
||||
mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }'
|
||||
````
|
||||
In the same way, you may subscribe to a topic with
|
||||
````
|
||||
mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/out'
|
||||
````
|
||||
|
||||
#### Upgrade from version without mosquitto
|
||||
If you have package ynh3 or below, mosquitto is not installed by default.
|
||||
If you have chosen to not set a domain during initial installation also.
|
||||
So, if you need to activate mosquitto in retrospect, do following actions:
|
||||
1. Create a domain or a subdomain (for example : 'mqtt.your.domain.tld')
|
||||
2. Connect to your server in command line
|
||||
3. Type following command : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld`
|
||||
4. Upgrade domoticz to last package.
|
||||
If you're already on the last package version, use the following command : `yunohost app upgrade domoticz --force`
|
||||
|
||||
## Configuration
|
||||
|
||||
|
@ -75,45 +113,30 @@ allow ::/1;
|
|||
This will authorized only IPv4 within local network to access your domoticz API.
|
||||
You may add individual IPv6 address in the same way.
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: Please use the [wiki](https://www.domoticz.com/wiki/Main_Page) and [user manual](https://www.domoticz.com/DomoticzManual.pdf) for further info.
|
||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
Both ARM and x86 architectures should be supported.
|
||||
Compiled sources are directly downloaded by the package.
|
||||
|
||||
## Limitations
|
||||
|
||||
* No user management nor LDAP integration This function is [not planned to be implemented into the app](https://github.com/domoticz/domoticz/issues/838), hence it's not planned into the package neither.
|
||||
* Backup cannot be restored on a different machine type (arm, x86...) as compiled sources are different
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
**More info on the documentation page:**
|
||||
https://yunohost.org/packaging_apps
|
||||
* Official app website: <https://domoticz.com/>
|
||||
* Official user documentation: <https://www.domoticz.com/DomoticzManual.pdf>
|
||||
* Official admin documentation: <https://www.domoticz.com/wiki/Main_Page>
|
||||
* Upstream app code repository: <https://github.com/domoticz/domoticz>
|
||||
* YunoHost documentation for this app: <https://yunohost.org/app_domoticz>
|
||||
* Report a bug: <https://github.com/YunoHost-Apps/domoticz_ynh/issues>
|
||||
|
||||
## Links
|
||||
## Developer info
|
||||
|
||||
* Report a bug: https://github.com/Yunohost-Apps/domoticz_ynh/issues
|
||||
* App website: https://domoticz.com/
|
||||
* Upstream app repository: https://github.com/domoticz/domoticz
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developer info
|
||||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please send your pull request to the [testing branch](https://github.com/Yunohost-Apps/domoticz_ynh/tree/testing).
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/Yunohost-Apps/domoticz_ynh/tree/testing --debug
|
||||
|
||||
``` bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade domoticz -u https://github.com/Yunohost-Apps/domoticz_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade domoticz -u https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>
|
||||
|
|
134
README_fr.md
134
README_fr.md
|
@ -1,43 +1,81 @@
|
|||
# App exemple pour YunoHost
|
||||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg)
|
||||
[![Installer domoticz avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=domoticz)
|
||||
# Domoticz pour YunoHost
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg)
|
||||
[![Installer Domoticz avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=domoticz)
|
||||
|
||||
> *Ce package vous permet d'installer domoticz rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
||||
> *Ce package vous permet d'installer Domoticz rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||
|
||||
## Vue d'ensemble
|
||||
|
||||
Logiciel open sources et gratuit de domotique qui vous permet de configurer un grand nombre d'appareils
|
||||
|
||||
**Version incluse :** 2020.2~ynh4
|
||||
## Avertissements / informations importantes
|
||||
|
||||
Domoticz est un système de domotique permettant de controler différents objets et de recevoir des données de divers senseurs
|
||||
Il peut par exemple être utilisé avec :
|
||||
|
||||
-des interrupteurs
|
||||
* des interrupteurs
|
||||
* des senseurs de portes
|
||||
* des sonnettes d'entrées
|
||||
* des systèmes de sécurité
|
||||
* des stations météo pour les UV, la pluie, le vent...
|
||||
* des sondes de températures
|
||||
* des sondes d'impulsions
|
||||
* des voltmètres
|
||||
* Et bien d'autres
|
||||
|
||||
-des senseurs de portes
|
||||
**Version incluse :** Toujours la dernière version stable. La dernière version compilée est récupérée dans [ce répertoire](https://releases.domoticz.com/releases/?dir=./beta) lors de l'installation.
|
||||
Une fois installée, **les mises à jour de l'application sont gérées depuis les menus de l'application elle même**. Le script de mise à jour Yunohost mettra uniquement à jour de nouvelles version du package.
|
||||
|
||||
-des sonnettes d'entrées
|
||||
|
||||
-des systèmes de sécurité
|
||||
|
||||
-des stations météo pour les UV, la pluie, le vent...
|
||||
|
||||
-des sondes de températures
|
||||
|
||||
-des sondes d'impulsions
|
||||
|
||||
-des voltmètres
|
||||
|
||||
-Et bien d'autres
|
||||
|
||||
**Version incluse :** Toujours la dernière version stable. La dernière version compilée est récupérée dans [ce répertoire](https://releases.domoticz.com/releases/?dir=./beta)
|
||||
Une fois installée, **les mises à jour de l'application sont gérées depuis les menus de l'application elle même.**. Le script de mise à jour Yunohost mettra uniquement à jour de nouvelles version du package.
|
||||
Le broker MQTT mosquitto est intégré au package et nécessite un sous-domaine ou un domaine distinct. Il est optionnel et si vous indiquez lors de l'installation le même domaine que le domaine principal, il ne sera pas installé.
|
||||
|
||||
## Configuration
|
||||
|
||||
### 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. La version installée est celle du dépot officiel du projet, et non des dépots Debian.
|
||||
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.
|
||||
|
||||
####Utilisation
|
||||
|
||||
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 en tapant
|
||||
````
|
||||
sudo yunohost app setting domoticz mqtt_user
|
||||
sudo yunohost app setting domoticz mqtt_pwd
|
||||
````
|
||||
|
||||
Vous pouvez ensuite publier sur ce serveur en utilisant la syntaxe:
|
||||
````
|
||||
mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }'
|
||||
````
|
||||
De la même manière, vous pouvez suivre ce qu'il se passe avec
|
||||
````
|
||||
mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/out'
|
||||
````
|
||||
|
||||
####Mise à jour depuis les versions n'ayant pas mosquitto
|
||||
Si vous êtes sur le package 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`
|
||||
|
||||
|
||||
### Senseurs, langue et ce genre de choses
|
||||
Toute la configuration de l'application a lieu dans l'application elle même
|
||||
Main configuration of the app take place inside the app itself.
|
||||
|
||||
### Accès et API
|
||||
Par défaut, l'accès aux [API JSON](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) est autorisé sur cette URL `/votredomaine.tld/api_/chemindedomoticz`.
|
||||
|
@ -74,46 +112,30 @@ allow ::/1;
|
|||
Ceci autorisera seulement les adresses IPv4 local a accéder aux API de domoticz.
|
||||
Vous pouvez ajouter des adresses IPv6 de la même façon.
|
||||
|
||||
## Documentation
|
||||
|
||||
* Documentation officielle : Utilisez le [wiki](https://www.domoticz.com/wiki/Main_Page) et le [manuel utilisateurs](https://www.domoticz.com/DomoticzManual.pdf) pour plus d'informations
|
||||
* Documentation YunoHost : Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
|
||||
|
||||
## Caractéristiques spécifiques YunoHost
|
||||
|
||||
|
||||
#### Architectures supportées
|
||||
|
||||
A la fois les architectures ARM et x86 devraient être supportées.
|
||||
Les sources compilées sont directement téléchargées par le package.
|
||||
|
||||
## Limitations
|
||||
|
||||
* Pas de gestion d'utilisateurs ni d'intégration LDAP. L'application ne [prévoit pas de gérer les utilisateurs par LDAP](https://github.com/domoticz/domoticz/issues/838), donc le package non plus.
|
||||
* Un backup ne peut pas être restauré sur un type de machine différente de celle d'origine (x86, arm...) car les sources compilées doivent être différente
|
||||
* Un backup ne peut pas être restauré sur un type de machine différente de celle d'origine (x86, arm...) car les sources compilées doivent être différentes
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
**Plus d'informations sur la page de documentation :**
|
||||
https://yunohost.org/packaging_apps
|
||||
* Site officiel de l'app : <https://domoticz.com/>
|
||||
* Documentation officielle utilisateur : <https://www.domoticz.com/DomoticzManual.pdf>
|
||||
* Documentation officielle de l'admin : <https://www.domoticz.com/wiki/Main_Page>
|
||||
* Dépôt de code officiel de l'app : <https://github.com/domoticz/domoticz>
|
||||
* Documentation YunoHost pour cette app : <https://yunohost.org/app_domoticz>
|
||||
* Signaler un bug : <https://github.com/YunoHost-Apps/domoticz_ynh/issues>
|
||||
|
||||
## Liens
|
||||
## Informations pour les développeurs
|
||||
|
||||
* Signaler un bug : https://github.com/Yunohost-Apps/domoticz_ynh/issues
|
||||
* Site de l'application : https://domoticz.com/
|
||||
* Dépôt de l'application principale : https://github.com/domoticz/domoticz
|
||||
* Site web YunoHost : https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Informations pour les développeurs
|
||||
----------------
|
||||
|
||||
**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.**
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/Yunohost-Apps/domoticz_ynh/tree/testing --debug
|
||||
|
||||
``` bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade domoticz -u https://github.com/Yunohost-Apps/domoticz_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade domoticz -u https://github.com/YunoHost-Apps/domoticz_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
;; Test complet
|
||||
;; Test avec Mosquitto
|
||||
; pre-install
|
||||
set -euxo pipefail
|
||||
yunohost domain add mqtt.domain.tld
|
||||
; pre-upgrade
|
||||
set -euxo pipefail
|
||||
yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
port="666"
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/domoticz" (PATH)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
mqtt_domain="mqtt.domain.tld"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -11,15 +17,38 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=cf402923ff6feeead1c87555c6e9207b8c7f6595
|
||||
upgrade=1 from_commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=1
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Email=nicolas@aubonalbanais.ovh
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
; commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b
|
||||
name=Package ynh3
|
||||
|
||||
;; Test sans Mosquitto
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/domoticz" (PATH)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
mqtt_domain="sub.domain.tld"
|
||||
; Checks
|
||||
pkg_linter=0
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b
|
||||
backup_restore=1
|
||||
port_already_use=1
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=nicolas@aubonalbanais.ovh
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b
|
||||
name=Package ynh3
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=http://www.domoticz.com/download.php?channel=release&type=release&system=__OS__&machine=__MACH__
|
||||
SOURCE_SUM=__SHA256_SUM__
|
||||
SOURCE_SUM=__SHA256__
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=false
|
||||
|
|
9
conf/domoticz_mosquitto.conf
Normal file
9
conf/domoticz_mosquitto.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
|
||||
listener __MQTT_PORT__
|
||||
|
||||
listener __MQTT_WEBSOCKET_PORT__
|
||||
protocol websockets
|
||||
|
||||
allow_anonymous false
|
||||
password_file /etc/mosquitto/conf.d/__APP___credentials
|
11
conf/mqtt_nginx.conf
Normal file
11
conf/mqtt_nginx.conf
Normal file
|
@ -0,0 +1,11 @@
|
|||
location / {
|
||||
|
||||
#Settings for mqtt server from outside
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://localhost:__MQTT_WEBSOCKET_PORT__;
|
||||
proxy_read_timeout 90;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
|
||||
}
|
|
@ -16,18 +16,11 @@ location __PATH__/ {
|
|||
#Allow upload until 10M to upload floorplan
|
||||
client_max_body_size 10M;
|
||||
|
||||
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
|
||||
#This part should be split in a second file to not be overwritten
|
||||
#sub_path_only rewrite ^api___PATH__$ api___PATH__/ permanent;
|
||||
location __API_PATH__/ {
|
||||
#Alternative path for api, only authorized json command will be accepted
|
||||
|
@ -63,9 +56,4 @@ location __API_PATH__/ {
|
|||
return 403;
|
||||
}
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,5 +12,39 @@ ExecStartPre=setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __FINALPATH__/do
|
|||
Restart=on-failure
|
||||
RestartSec=1m
|
||||
#StandardOutput=null
|
||||
|
||||
# Sandboxing options to harden security
|
||||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
ProtectSystem=full
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
# Denying access to capabilities that should not be relevant for webapps
|
||||
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
|
||||
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
|
||||
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
|
||||
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
|
||||
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
|
||||
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
|
||||
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
|
||||
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
|
||||
#Has to be commented as prevent the service to run
|
||||
#CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
|
||||
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
|
||||
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -1,28 +1,55 @@
|
|||
Domoticz is a Home Automation system design to control various devices and receive input from various sensors.
|
||||
For example this system can be used with:
|
||||
|
||||
-Light switches
|
||||
|
||||
-Door sensors
|
||||
|
||||
-Doorbells
|
||||
|
||||
-Security devices
|
||||
|
||||
-Weather sensors like: UV/Rain/Wind Meters
|
||||
|
||||
-Temperature Sensors
|
||||
|
||||
-Pulse Meters
|
||||
|
||||
-Voltage / AD Meters
|
||||
|
||||
-And more ...
|
||||
* Light switches
|
||||
* Door sensors
|
||||
* Doorbells
|
||||
* Security devices
|
||||
* Weather sensors like: UV/Rain/Wind Meters
|
||||
* Temperature Sensors
|
||||
* Pulse Meters
|
||||
* Voltage / AD Meters
|
||||
* And more ...
|
||||
|
||||
|
||||
**Shipped version:** Always the last stable one. The last compiled version is retrieved from [this directory](https://releases.domoticz.com/releases/?dir=./beta)
|
||||
Once installed, **updates from the uptream app are managed from within the app.**. Yunohost upgrade script will only upgrade the Yunohost package.
|
||||
**Shipped version:** Always the last stable one. The last compiled version is retrieved from [this directory](https://releases.domoticz.com/releases/?dir=./beta) during install.
|
||||
Once installed, **updates from the uptream app are managed from within the app**. Yunohost upgrade script will only upgrade the Yunohost package.
|
||||
|
||||
The MQTT broker mosquitto is integrated into the package. It requires its own domain or subdomain. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Broker Mosquitto
|
||||
|
||||
During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), is installed at the same time as Domoticz. The installed version is the one from the official project repo and not from Debian ones.
|
||||
This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite
|
||||
|
||||
#### Use
|
||||
|
||||
To use mosquitto, you need to customize the communication between domoticz and the broker by following the [domoticz documentation](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto), part *Add hardware "MQTT Client Gateway"*.
|
||||
User and password are automatically generated during installation, you may retrieve them with
|
||||
````
|
||||
sudo yunohost app setting domoticz mqtt_user
|
||||
sudo yunohost app setting domoticz mqtt_pwd
|
||||
````
|
||||
You can then publish on a device on domoticz with following syntax:
|
||||
````
|
||||
mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }'
|
||||
````
|
||||
In the same way, you may subscribe to a topic with
|
||||
````
|
||||
mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/out'
|
||||
````
|
||||
|
||||
#### Upgrade from version without mosquitto
|
||||
If you have package ynh3 or below, mosquitto is not installed by default.
|
||||
If you have chosen to not set a domain during initial installation also.
|
||||
So, if you need to activate mosquitto in retrospect, do following actions:
|
||||
1. Create a domain or a subdomain (for example : 'mqtt.your.domain.tld')
|
||||
2. Connect to your server in command line
|
||||
3. Type following command : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld`
|
||||
4. Upgrade domoticz to last package.
|
||||
If you're already on the last package version, use the following command : `yunohost app upgrade domoticz --force`
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
|
@ -1,42 +1,69 @@
|
|||
Domoticz est un système de domotique permettant de controler différents objets et de recevoir des données de divers senseurs
|
||||
Il peut par exemple être utilisé avec :
|
||||
Domoticz est un système de domotique permettant de controler différents objets et de recevoir des données de divers senseurs
|
||||
Il peut par exemple être utilisé avec :
|
||||
|
||||
-des interrupteurs
|
||||
* des interrupteurs
|
||||
* des senseurs de portes
|
||||
* des sonnettes d'entrées
|
||||
* des systèmes de sécurité
|
||||
* des stations météo pour les UV, la pluie, le vent...
|
||||
* des sondes de températures
|
||||
* des sondes d'impulsions
|
||||
* des voltmètres
|
||||
* Et bien d'autres
|
||||
|
||||
-des senseurs de portes
|
||||
**Version incluse :** Toujours la dernière version stable. La dernière version compilée est récupérée dans [ce répertoire](https://releases.domoticz.com/releases/?dir=./beta) lors de l'installation.
|
||||
Une fois installée, **les mises à jour de l'application sont gérées depuis les menus de l'application elle même**. Le script de mise à jour Yunohost mettra uniquement à jour de nouvelles version du package.
|
||||
|
||||
-des sonnettes d'entrées
|
||||
|
||||
-des systèmes de sécurité
|
||||
|
||||
-des stations météo pour les UV, la pluie, le vent...
|
||||
|
||||
-des sondes de températures
|
||||
|
||||
-des sondes d'impulsions
|
||||
|
||||
-des voltmètres
|
||||
|
||||
-Et bien d'autres
|
||||
|
||||
**Version incluse :** Toujours la dernière version stable. La dernière version compilée est récupérée dans [ce répertoire](https://releases.domoticz.com/releases/?dir=./beta)
|
||||
Une fois installée, **les mises à jour de l'application sont gérées depuis les menus de l'application elle même.**. Le script de mise à jour Yunohost mettra uniquement à jour de nouvelles version du package.
|
||||
Le broker MQTT mosquitto est intégré au package et nécessite un sous-domaine ou un domaine distinct. Il est optionnel et si vous indiquez lors de l'installation le même domaine que le domaine principal, il ne sera pas installé.
|
||||
|
||||
## Configuration
|
||||
|
||||
### 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. La version installée est celle du dépot officiel du projet, et non des dépots Debian.
|
||||
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.
|
||||
|
||||
####Utilisation
|
||||
|
||||
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 en tapant
|
||||
````
|
||||
sudo yunohost app setting domoticz mqtt_user
|
||||
sudo yunohost app setting domoticz mqtt_pwd
|
||||
````
|
||||
|
||||
Vous pouvez ensuite publier sur ce serveur en utilisant la syntaxe:
|
||||
````
|
||||
mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }'
|
||||
````
|
||||
De la même manière, vous pouvez suivre ce qu'il se passe avec
|
||||
````
|
||||
mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 443 -t 'domoticz/out'
|
||||
````
|
||||
|
||||
####Mise à jour depuis les versions n'ayant pas mosquitto
|
||||
Si vous êtes sur le package 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`
|
||||
|
||||
|
||||
### Senseurs, langue et ce genre de choses
|
||||
Toute la configuration de l'application a lieu dans l'application elle même
|
||||
Main configuration of the app take place inside the app itself.
|
||||
Toute la configuration de l'application a lieu dans l'application elle même
|
||||
|
||||
### Accès et API
|
||||
Par défaut, l'accès aux [API JSON](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) est autorisé sur cette URL `/votredomaine.tld/api_/chemindedomoticz`.
|
||||
Donc, si vous accédez à domoticz par https://votredomaine.tld/domoticz, utilisez le chemin suivant pour l'api: `/votredomaine.tld/api_/domoticz/json.htm?votrecommandeapi`
|
||||
### Accès et API
|
||||
Par défaut, l'accès aux [API JSON](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) est autorisé sur cette URL `/votredomaine.tld/api_/chemindedomoticz`.
|
||||
Donc, si vous accédez à domoticz par https://votredomaine.tld/domoticz, utilisez le chemin suivant pour l'api: `/votredomaine.tld/api_/domoticz/json.htm?votrecommandeapi`
|
||||
|
||||
Par défaut, seuls la mise à jour de senseur et les interrupteurs sont autorisés. Pour autoriser une nouvelle commande, vous devez (pour l'instant) manuellement éditer le fichier de configuration nginx :
|
||||
Par défaut, seuls la mise à jour de senseur et les interrupteurs sont autorisés. Pour autoriser une nouvelle commande, vous devez (pour l'instant) manuellement éditer le fichier de configuration nginx :
|
||||
````
|
||||
sudo nano /etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf
|
||||
````
|
||||
Puis éditer le bloc suivant en y ajoutant le regex de la commmande à autoriser :
|
||||
Puis éditer le bloc suivant en y ajoutant le regex de la commmande à autoriser :
|
||||
````
|
||||
#set the list of authorized json command here in regex format
|
||||
#you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
|
||||
|
@ -45,7 +72,7 @@ Puis
|
|||
set $api "1";
|
||||
}
|
||||
````
|
||||
Par exemple, pour ajouter la commmande json pour retrouver le statut d'un équipement (/json.htm?type=devices&rid=IDX),il faut modifier la ligne comme ceci:
|
||||
Par exemple, pour ajouter la commmande json pour retrouver le statut d'un équipement (/json.htm?type=devices&rid=IDX),il faut modifier la ligne comme ceci:
|
||||
````
|
||||
#set the list of authorized json command here in regex format
|
||||
#you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
|
||||
|
@ -55,15 +82,15 @@ Par exemple, pour ajouter la commmande json pour retrouver le statut d'un
|
|||
}
|
||||
````
|
||||
|
||||
Toutes les adresses IPv4 du réseau local (192.168.0.0/24) et toutes les adresses IPv6 sont autorisées pour l'API.
|
||||
A ma connaissance, il n'y a pas moyen d'effectuer un filtre pour les adresses IPv6 sur le réseau local, vous pouvez donc retirer leur autorisation en enlevant ou en commentant la ligne suivante dans `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`:
|
||||
Toutes les adresses IPv4 du réseau local (192.168.0.0/24) et toutes les adresses IPv6 sont autorisées pour l'API.
|
||||
A ma connaissance, il n'y a pas moyen d'effectuer un filtre pour les adresses IPv6 sur le réseau local, vous pouvez donc retirer leur autorisation en enlevant ou en commentant la ligne suivante dans `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`:
|
||||
````
|
||||
allow ::/1;
|
||||
````
|
||||
Ceci autorisera seulement les adresses IPv4 local a accéder aux API de domoticz.
|
||||
Vous pouvez ajouter des adresses IPv6 de la même façon.
|
||||
Ceci autorisera seulement les adresses IPv4 local a accéder aux API de domoticz.
|
||||
Vous pouvez ajouter des adresses IPv6 de la même façon.
|
||||
|
||||
## Limitations
|
||||
|
||||
* Pas de gestion d'utilisateurs ni d'intégration LDAP. L'application ne [prévoit pas de gérer les utilisateurs par LDAP](https://github.com/domoticz/domoticz/issues/838), donc le package non plus.
|
||||
* Un backup ne peut pas être restauré sur un type de machine différente de celle d'origine (x86, arm...) car les sources compilées doivent être différente
|
||||
* Pas de gestion d'utilisateurs ni d'intégration LDAP. L'application ne [prévoit pas de gérer les utilisateurs par LDAP](https://github.com/domoticz/domoticz/issues/838), donc le package non plus.
|
||||
* Un backup ne peut pas être restauré sur un type de machine différente de celle d'origine (x86, arm...) car les sources compilées doivent être différentes
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Very light weight open sources home automation system that lets you monitor and configure miscellaneous devices",
|
||||
"fr": "Logiciel open sources et gratuit de domotique qui vous permet de configurer un grand nombre d'appareils"
|
||||
},
|
||||
"version": "2020.2~ynh3",
|
||||
"version": "2020.2~ynh4",
|
||||
"url": "https://www.domoticz.com",
|
||||
"upstream": {
|
||||
"license": "GPL-3.0-or-later",
|
||||
|
@ -31,8 +31,7 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "example.com"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
|
@ -44,7 +43,24 @@
|
|||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"help": "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": {
|
||||
"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!",
|
||||
"en": "Beware, there is no user management by default. If it's set as public, anyone will have access!"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mqtt_domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"fr":"Domaine MQTT",
|
||||
"en":"MQTT domain"
|
||||
},
|
||||
"example": "mqtt.your.domain.com",
|
||||
"optional": true,
|
||||
"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",
|
||||
"en": "MQTT server domain. Set the main domain if you don't wish to use it. See the doc for more info"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,8 +6,13 @@
|
|||
|
||||
# dependencies used by the app
|
||||
#python3-dev required as per https://www.domoticz.com/forum/viewtopic.php?f=65&t=16116&p=119747
|
||||
#mosquitto and mosquitto-clients are required for mqtt
|
||||
#other dependencies are from standard install script... seems quite useles...
|
||||
pkg_dependencies="libudev-dev python3-dev"
|
||||
extra_pkg_dependencies="mosquitto mosquitto-clients"
|
||||
|
||||
default_mqtt_port=1883
|
||||
default_mqtt_websocket_port=8083
|
||||
|
||||
#ALL FOLLOWING LINE FROM THE upstream bash installation script
|
||||
DEBIAN_ID=$(grep -oP '(?<=^ID=).+' /etc/*-release | tr -d '"')
|
||||
|
@ -24,13 +29,13 @@ lowercase(){
|
|||
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
}
|
||||
|
||||
OS=`lowercase \`uname -s\``
|
||||
MACH=`uname -m`
|
||||
if [ ${MACH} = "armv6l" ]
|
||||
os=`lowercase \`uname -s\``
|
||||
mach=`uname -m`
|
||||
if [ ${mach} = "armv6l" ]
|
||||
then
|
||||
MACH="armv7l"
|
||||
mach="armv7l"
|
||||
fi
|
||||
SHA256=$(wget -qO- https://releases.domoticz.com/releases/release/domoticz_${OS}_${MACH}.tgz.sha256sum | sed 's/ update.tgz//' | sed 's/ domoticz_linux_x86_64.tgz//')
|
||||
sha256=$(wget -qO- https://releases.domoticz.com/releases/release/domoticz_${os}_${mach}.tgz.sha256sum | sed 's/ update.tgz//' | sed 's/ domoticz_linux_x86_64.tgz//')
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
mqtt_domain=$(ynh_app_setting_get --app=$app --key=mqtt_domain)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -46,6 +47,7 @@ ynh_backup --src_path="$final_path"
|
|||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -66,6 +68,8 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/sudoers.d/$app"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -38,7 +38,6 @@ else
|
|||
fi
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
|
130
scripts/install
130
scripts/install
|
@ -23,61 +23,81 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
domain="$YNH_APP_ARG_DOMAIN"
|
||||
path_url="$YNH_APP_ARG_PATH"
|
||||
is_public="$YNH_APP_ARG_IS_PUBLIC"
|
||||
mqtt_domain="$YNH_APP_ARG_MQTT_DOMAIN"
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
#Set dedicated variables
|
||||
if [ "$path_url" == "/" ]; then
|
||||
api_path=/api_/$app
|
||||
api_path=/api_/"$app"
|
||||
else
|
||||
api_path=/api_$path_url
|
||||
api_path=/api_"$path_url"
|
||||
fi
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
final_path=/opt/yunohost/"$app"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
||||
#impossible de booker plusieurs webpath
|
||||
#if [ ! -z $mqtt_domain ]; then
|
||||
# ynh_webpath_register --app=mqtt_$app --domain=$mqtt_domain --path_url="/"
|
||||
#fi
|
||||
|
||||
if [ "$domain" == "$mqtt_domain" ]; then
|
||||
mqtt_domain=""
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
||||
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
||||
|
||||
#Will be used in restore script to check that we're restoring on the same OS/Board type
|
||||
ynh_app_setting_set --app=$app --key=OS --value=$OS
|
||||
ynh_app_setting_set --app=$app --key=mach --value=$MACH
|
||||
ynh_app_setting_set --app="$app" --key=OS --value="$os"
|
||||
ynh_app_setting_set --app="$app" --key=mach --value="$mach"
|
||||
|
||||
#path used by api & mqtt to read/update domoticz
|
||||
ynh_app_setting_set --app="$app" --key=api_path --value="$api_path"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain"
|
||||
|
||||
#path used by api to read/update domoticz
|
||||
ynh_app_setting_set --app=$app --key=api_path --value=$api_path
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
ynh_script_progression --message="Finding available port..."
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=8080)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
ynh_app_setting_set --app="$app" --key=port --value="$port"
|
||||
|
||||
if [ ! -z "$mqtt_domain" ]; then
|
||||
ynh_script_progression --message="Finding available ports for Mosquitto..."
|
||||
mqtt_port=$(ynh_find_port --port="$default_mqtt_port")
|
||||
ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
||||
|
||||
mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port")
|
||||
ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=15
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -85,59 +105,80 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
||||
#allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus
|
||||
if grep dialout -q < /etc/group; then
|
||||
usermod -a -G dialout $app
|
||||
usermod -a -G dialout "$app"
|
||||
fi
|
||||
if grep i2c -q < /etc/group; then
|
||||
usermod -a -G i2c $app
|
||||
usermod -a -G i2c "$app"
|
||||
fi
|
||||
if grep gpio -q < /etc/group; then
|
||||
usermod -a -G gpio $app
|
||||
usermod -a -G gpio "$app"
|
||||
fi
|
||||
|
||||
#allow app user to restart service on startup
|
||||
cp ../conf/sudoer ../conf/$app.conf
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/$app.conf"
|
||||
mv ../conf/$app.conf /etc/sudoers.d/$app
|
||||
chmod 440 /etc/sudoers.d/$app
|
||||
ynh_add_config --template="../conf/sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chmod 440 /etc/sudoers.d/"$app"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# Create an app.src for the correct version of domoticz
|
||||
# match string are fulfilled in _common.sh via the upstream bash installation script
|
||||
cp ../conf/app.src.default ../conf/app.src
|
||||
ynh_replace_string --match_string="__OS__" --replace_string="$OS" --target_file="../conf/app.src"
|
||||
ynh_replace_string --match_string="__MACH__" --replace_string="$MACH" --target_file="../conf/app.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$SHA256" --target_file="../conf/app.src"
|
||||
ynh_add_config --template="../conf/app.src.default" --destination="../conf/app.src"
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
#Create the database file
|
||||
if [ ! -f $final_path/domoticz.db ]; then
|
||||
touch $final_path/domoticz.db
|
||||
chmod 640 $final_path/domoticz.db
|
||||
if [ ! -f "$final_path"/domoticz.db ]; then
|
||||
touch "$final_path"/domoticz.db
|
||||
chmod 640 "$final_path"/domoticz.db
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R "$app":"$app" "$final_path"
|
||||
|
||||
|
||||
#=================================================
|
||||
# SET MOSQUITTO SETTINGS
|
||||
#=================================================
|
||||
if [ ! -z "$mqtt_domain" ]; then
|
||||
|
||||
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
||||
|
||||
#Installing packages
|
||||
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"
|
||||
|
||||
#Setting up conf file for access
|
||||
ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/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
|
||||
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -155,18 +196,21 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
chown -R domoticz: /var/log/$app
|
||||
mkdir -p /var/log/"$app"
|
||||
chown -R domoticz: /var/log/"$app"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto/"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
[[ ! -z "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -174,7 +218,11 @@ yunohost service add $app --description="Domotique open sources" --log="/var/log
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
ynh_systemd_action --service_name="$app" --action="start"
|
||||
|
||||
#Restarting mosquitto to take changes into account
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
|
@ -182,15 +230,17 @@ ynh_systemd_action --service_name=$app --action="start"
|
|||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
if [ "$is_public" -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#API should stay publicly accessible.
|
||||
#API & MQTT should stay publicly accessible.
|
||||
ynh_permission_create --permission="domoticz_API" --url="$domain$api_path" --allowed="visitors"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --url="$mqtt_domain" --allowed="visitors"
|
||||
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
|
|
@ -14,13 +14,12 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -29,10 +28,11 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
|
||||
# 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
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
yunohost service remove "$app"
|
||||
[[ ! -z "$mqtt_domain" ]] && yunohost service remove mosquitto
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -44,12 +44,23 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
|||
ynh_remove_systemd_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=3
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/mosquitto/conf.d"
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
|
@ -66,6 +77,8 @@ ynh_secure_remove --file="$final_path"
|
|||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
|
||||
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -85,6 +98,7 @@ ynh_script_progression --message="Removing various files..."
|
|||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/var/log/mosquitto"
|
||||
|
||||
#Delete the sudoer file
|
||||
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
||||
|
@ -97,7 +111,7 @@ ynh_secure_remove --file="/etc/sudoers.d/$app"
|
|||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
ynh_system_user_delete --username="$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -25,32 +25,27 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
backup_OS=$(ynh_app_setting_get --app=$app --key=OS)
|
||||
backup_mach=$(ynh_app_setting_get --app=$app --key=mach)
|
||||
api_path=$(ynh_app_setting_get --app=$app --key=api_path)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
backup_OS=$(ynh_app_setting_get --app="$app" --key=OS)
|
||||
backup_mach=$(ynh_app_setting_get --app="$app" --key=mach)
|
||||
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
#ynh_webpath_available --domain=$domain --path_url=$api_path \
|
||||
# || ynh_die --message="Path not available: ${domain}${api_path}"
|
||||
test ! -d $final_path \
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
#As we are downloading compiled binaries for each system, we have to check if the restore occurs
|
||||
#on the same system type. If we are restoring on another system type it won't work and in that
|
||||
#case we must go through a reinstall process.
|
||||
test "$backup_OS" = "$OS" \
|
||||
test "$backup_OS" = "$os" \
|
||||
|| ynh_die --message="Cannot restore : previous OS is $backup_OS, current OS is $OS, please reinstall"
|
||||
test "$backup_mach" = "$MACH" \
|
||||
test "$backup_mach" = "$mach" \
|
||||
|| ynh_die --message="Cannot restore : previous machine type is $backup_mach, current machine type is $MACH, please reinstall"
|
||||
|
||||
#=================================================
|
||||
|
@ -61,6 +56,7 @@ test "$backup_mach" = "$MACH" \
|
|||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
|
@ -68,17 +64,17 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
||||
#allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus
|
||||
if grep dialout -q < /etc/group; then
|
||||
usermod -a -G dialout $app
|
||||
usermod -a -G dialout "$app"
|
||||
fi
|
||||
if grep i2c -q < /etc/group; then
|
||||
usermod -a -G i2c $app
|
||||
usermod -a -G i2c "$app"
|
||||
fi
|
||||
if grep gpio -q < /etc/group; then
|
||||
usermod -a -G gpio $app
|
||||
usermod -a -G gpio "$app"
|
||||
fi
|
||||
|
||||
#Restore user authorization to restart server
|
||||
|
@ -93,7 +89,7 @@ ynh_restore_file --origin_path="$final_path"
|
|||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R "$app":"$app" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -103,7 +99,19 @@ chown -R $app:$app "$final_path"
|
|||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SET MOSQUITTO SETTINGS
|
||||
#=================================================
|
||||
if [ ! -z "$mqtt_domain" ]; then
|
||||
ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5
|
||||
|
||||
#Installing packages
|
||||
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"
|
||||
#reinstalling settings
|
||||
ynh_restore_file --origin_path="/etc/mosquitto/conf.d" --not_mandatory
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
@ -111,31 +119,37 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=3
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
systemctl enable "$app".service --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
[[ ! -z "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#Restarting mosquitto to take changes into account
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
chown -R domoticz: /var/log/$app
|
||||
mkdir -p /var/log/"$app"
|
||||
chown -R domoticz: /var/log/"$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
146
scripts/upgrade
146
scripts/upgrade
|
@ -18,15 +18,18 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
current_OS=$(ynh_app_setting_get --app=$app --key=OS)
|
||||
current_mach=$(ynh_app_setting_get --app=$app --key=mach)
|
||||
api_path=$(ynh_app_setting_get --app=$app --key=api_path)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||
current_OS=$(ynh_app_setting_get --app="$app" --key=OS)
|
||||
current_mach=$(ynh_app_setting_get --app="$app" --key=mach)
|
||||
api_path=$(ynh_app_setting_get --app="$app" --key=api_path)
|
||||
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
||||
mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port)
|
||||
mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -38,14 +41,14 @@ 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)..."0
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Ugly hack so that previous version backup script from "https://github.com/anubister/domoticz_ynh" works :
|
||||
# It creates a dummy file in /etc/cron.d so that the backup do not fail.
|
||||
current_upstream_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")
|
||||
current_package_version=$(ynh_app_package_version --manifest="/etc/yunohost/apps/$app/manifest.json")
|
||||
if version_gt "4.9701" "$current_upstream_version" && version_gt "2" $current_package_version ; then
|
||||
touch /etc/cron.d/$app
|
||||
if version_gt "4.9701" "$current_upstream_version" && version_gt "2" "$current_package_version" ; then
|
||||
touch /etc/cron.d/"$app"
|
||||
fi
|
||||
|
||||
# Backup the current version of the app
|
||||
|
@ -57,8 +60,8 @@ ynh_clean_setup () {
|
|||
}
|
||||
|
||||
#remove ugly hack
|
||||
if [ -f /etc/cron.d/$app ]; then
|
||||
rm /etc/cron.d/$app
|
||||
if [ -f /etc/cron.d/"$app" ]; then
|
||||
rm /etc/cron.d/"$app"
|
||||
fi
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -71,7 +74,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -80,33 +83,51 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
|||
|
||||
#Store OS and machine (to be used in restore script)
|
||||
if [ -z "$current_OS" ]; then
|
||||
ynh_app_setting_set --app=$app --key=OS --value=$OS
|
||||
ynh_app_setting_set --app="$app" --key=OS --value="$OS"
|
||||
fi
|
||||
if [ -z "$current_mach" ]; then
|
||||
ynh_app_setting_set --app=$app --key=mach --value=$MACH
|
||||
ynh_app_setting_set --app="$app" --key=mach --value="$MACH"
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
final_path=/var/www/"$app"
|
||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||
fi
|
||||
|
||||
#Create a dedicated path for the api access
|
||||
if [ -z "$api_path" ]; then
|
||||
if [ "$path_url" == "/" ]; then
|
||||
api_path=/api_/$app
|
||||
api_path=/api_/"$app"
|
||||
else
|
||||
api_path=/api_$path_url
|
||||
api_path=/api_"$path_url"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=api_path --value=$api_path
|
||||
ynh_app_setting_set --app="$app" --key=api_path --value="$api_path"
|
||||
fi
|
||||
|
||||
#Create a dedicated path for the mqtt access
|
||||
if [ -z "$mqtt_domain" ]; then
|
||||
ynh_print_info --message="Mosquitto, a mqtt server, can now be installed during upgrade, pleaser refer to package documentation to activate it"
|
||||
fi
|
||||
|
||||
#Port to listen for MQTT internal
|
||||
if [[ -z "$mqtt_port" && ! -z "$mqtt_domain" ]]; then
|
||||
mqtt_port=$(ynh_find_port --port="$default_mqtt_port")
|
||||
ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
||||
fi
|
||||
|
||||
#Port to listen for MQTT websocket
|
||||
if [[ -z "$mqtt_websocket_port" && ! -z "$mqtt_domain" ]]; then
|
||||
mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port")
|
||||
ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port"
|
||||
fi
|
||||
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
ynh_app_setting_delete --app="$app" --key=is_public
|
||||
fi
|
||||
|
||||
# Create the permission "domoticz_API" only if it doesn't exist.
|
||||
|
@ -116,30 +137,38 @@ then
|
|||
ynh_permission_create --permission="domoticz_API" --url="$domain$api_path" --allowed="visitors"
|
||||
fi
|
||||
|
||||
# Create the permission "domoticz_MQTT" only if it doesn't exist.
|
||||
if [ ! -z "$mqtt_domain" ]; then
|
||||
if ! ynh_permission_exists --permission="domoticz_MQTT"
|
||||
then
|
||||
# API Authorization with dedicated URL
|
||||
ynh_permission_create --permission="domoticz_MQTT" --url="$mqtt_domain" --allowed="visitors"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
||||
#allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus
|
||||
if grep dialout -q < /etc/group; then
|
||||
usermod -a -G dialout $app
|
||||
usermod -a -G dialout "$app"
|
||||
fi
|
||||
if grep i2c -q < /etc/group; then
|
||||
usermod -a -G i2c $app
|
||||
usermod -a -G i2c "$app"
|
||||
fi
|
||||
if grep gpio -q < /etc/group; then
|
||||
usermod -a -G gpio $app
|
||||
usermod -a -G gpio "$app"
|
||||
fi
|
||||
|
||||
#allow app user to restart service on startup
|
||||
cp ../conf/sudoer ../conf/$app.conf
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/$app.conf"
|
||||
mv ../conf/$app.conf /etc/sudoers.d/$app
|
||||
chmod 440 /etc/sudoers.d/$app
|
||||
ynh_add_config --template="../conf/sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chmod 440 /etc/sudoers.d/"$app"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -150,27 +179,51 @@ then
|
|||
ynh_script_progression --message="Upgrading source files..." --weight=15
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
cp ../conf/app.src.default ../conf/app.src
|
||||
ynh_replace_string --match_string="__OS__" --replace_string="$OS" --target_file="../conf/app.src"
|
||||
ynh_replace_string --match_string="__MACH__" --replace_string="$MACH" --target_file="../conf/app.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$SHA256" --target_file="../conf/app.src"
|
||||
ynh_add_config --template="../conf/app.src.default" --destination="../conf/app.src"
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
#Create the database file
|
||||
if [ ! -f $final_path/domoticz.db ]; then
|
||||
touch $final_path/domoticz.db
|
||||
chmod 644 $final_path/domoticz.db
|
||||
if [ ! -f "$final_path"/domoticz.db ]; then
|
||||
touch "$final_path"/domoticz.db
|
||||
chmod 644 "$final_path"/domoticz.db
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R "$app":"$app" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SET MOSQUITTO SETTINGS
|
||||
#=================================================
|
||||
if [ ! -z "$mqtt_domain" ]; then
|
||||
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
||||
|
||||
#Installing packages
|
||||
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"
|
||||
|
||||
#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"
|
||||
|
||||
#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..."
|
||||
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
|
||||
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
@ -179,7 +232,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
|
@ -198,25 +251,32 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
chown -R domoticz: /var/log/$app
|
||||
mkdir -p /var/log/"$app"
|
||||
chown -R domoticz: /var/log/"$app"
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto/" --non-append
|
||||
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
yunohost service add "$app" --description="Domotique open sources" --log="/var/log/$app/$app.log"
|
||||
[[ ! -z "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
ynh_systemd_action --service_name="$app" --action="start"
|
||||
|
||||
#Restarting mosquitto to take changes from /etc/mosquitto/conf.d/*.conf into account
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
|
Loading…
Reference in a new issue