mirror of
https://github.com/YunoHost-Apps/domoticz_ynh.git
synced 2024-09-03 18:26:17 +02:00
mosquitto for v2
This commit is contained in:
parent
cc503b7c1a
commit
47e2c52ca0
10 changed files with 86 additions and 119 deletions
|
@ -1,9 +1,9 @@
|
||||||
log_timestamp_format %Y-%m-%dT%H:%M:%S
|
log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||||
|
|
||||||
listener __MQTT_PORT__ 127.0.0.1
|
listener __PORT_MQTT__ 127.0.0.1
|
||||||
listener __MQTT_PORT__ ::1
|
listener __PORT_MQTT__ ::1
|
||||||
|
|
||||||
listener __MQTT_WEBSOCKET_PORT__
|
listener __PORT_MQTT_WEBSOCKET__
|
||||||
protocol websockets
|
protocol websockets
|
||||||
|
|
||||||
allow_anonymous false
|
allow_anonymous false
|
||||||
|
|
|
@ -2,7 +2,7 @@ location / {
|
||||||
|
|
||||||
#Settings for mqtt server from outside
|
#Settings for mqtt server from outside
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_pass http://localhost:__MQTT_WEBSOCKET_PORT__;
|
proxy_pass http://localhost:__PORT_MQTT_WEBSOCKET__;
|
||||||
proxy_read_timeout 90;
|
proxy_read_timeout 90;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
|
@ -81,13 +81,11 @@ ram.runtime = "50M"
|
||||||
[resources.ports]
|
[resources.ports]
|
||||||
main.default = 8080
|
main.default = 8080
|
||||||
#to be checked if it can become conditionnal
|
#to be checked if it can become conditionnal
|
||||||
#mqtt.default = 1883
|
#ports will always be provisionned... don't know if it's an issue...
|
||||||
#mqtt_websocket.default = 8883
|
mqtt.default = 1883
|
||||||
|
mqtt_websocket.default = 8883
|
||||||
|
|
||||||
[resources.apt]
|
[resources.apt]
|
||||||
packages = "libudev-dev, python3-dev, libcurl4, libusb-0.1-4"
|
packages = "libudev-dev, python3-dev, libcurl4, libusb-0.1-4"
|
||||||
|
packages_from_raw_bash = '''if [ "$mqtt_domain" != "$domain" ]; then echo mosquitto mosquitto-clients; fi'''
|
||||||
|
|
||||||
#[[resources.apt.extras]]
|
|
||||||
#repo = "deb https://repo.mosquitto.org/debian buster main"
|
|
||||||
#key = "http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key"
|
|
||||||
#packages = "#FIXME#$extra_pkg_dependencies
|
|
|
@ -4,25 +4,6 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#mosquitto and mosquitto-clients are required for mqtt
|
|
||||||
extra_pkg_dependencies="mosquitto mosquitto-clients"
|
|
||||||
|
|
||||||
default_mqtt_port=1883
|
|
||||||
default_mqtt_websocket_port=8883
|
|
||||||
|
|
||||||
|
|
||||||
lowercase(){
|
|
||||||
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
|
||||||
}
|
|
||||||
|
|
||||||
OS=`lowercase \`uname -s\``
|
|
||||||
mach=`uname -m`
|
|
||||||
if [ ${mach} = "armv6l" ]
|
|
||||||
then
|
|
||||||
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//')
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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/$app.conf"
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/api_"$app".conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/api_"$app".conf"
|
||||||
[[ "$mqtt_domain" != "$domain" ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
|
@ -54,7 +54,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
# BACKUP VARIOUS FILES
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
|
||||||
|
|
||||||
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,20 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
#Will be used in restore script to check that we're restoring on the same OS/Board type
|
#Will be used in restore script to check that we're restoring on the same OS/Board type
|
||||||
|
lowercase(){
|
||||||
|
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||||
|
}
|
||||||
|
|
||||||
|
OS=`lowercase \`uname -s\``
|
||||||
|
mach=`uname -m`
|
||||||
|
if [ ${mach} = "armv6l" ]
|
||||||
|
then
|
||||||
|
mach="armv7l"
|
||||||
|
fi
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=OS --value="$OS"
|
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=mach --value="$mach"
|
||||||
|
|
||||||
#Settings for mosquitto. We store empty values so that they may be automatically retrieved and bound in other scripts.
|
|
||||||
if [ "$domain" == "$mqtt_domain" ]; then
|
|
||||||
mqtt_domain=""
|
|
||||||
#packaging v2 : settings are automatically stored. We overide the values
|
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain"
|
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_port --value=""
|
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
#path used by api to read/update domoticz
|
#path used by api to read/update domoticz
|
||||||
#Set dedicated variables
|
#Set dedicated variables
|
||||||
if [ "$path" == "/" ]; then
|
if [ "$path" == "/" ]; then
|
||||||
|
@ -76,21 +78,9 @@ chown -R "$app":"$app" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET MOSQUITTO SETTINGS
|
# SET MOSQUITTO SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
if [ ! -z "$mqtt_domain" ]; then
|
if [ "$domain" != "$mqtt_domain" ]; then
|
||||||
|
|
||||||
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
|
|
||||||
#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
|
#Setting up conf file for access
|
||||||
ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/etc/mosquitto/conf.d/"$app"_mosquitto.conf"
|
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
|
chmod 644 /etc/mosquitto/conf.d/"$app"_mosquitto.conf
|
||||||
|
@ -110,7 +100,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
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"
|
[[ "$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
|
#Set Hook for nginx domain
|
||||||
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
||||||
|
@ -142,7 +132,7 @@ chown -R domoticz: /var/log/"$app"
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto"
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
@ -150,7 +140,7 @@ ynh_use_logrotate
|
||||||
ynh_script_progression --message="Integrating 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"
|
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -162,7 +152,7 @@ ynh_script_progression --message="Starting 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
|
#Restarting mosquitto to take changes into account
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
|
@ -190,7 +180,7 @@ ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
#API & MQTT should stay publicly accessible.
|
#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"
|
#ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true"
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --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"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -z "$mqtt_domain" ]; then
|
if [ "$domain" != "$mqtt_domain" ]; then
|
||||||
ynh_script_progression --message="Removing system configurations related to Mosquitto..." --weight=1
|
ynh_script_progression --message="Removing system configurations related to Mosquitto..." --weight=1
|
||||||
yunohost service remove mosquitto
|
yunohost service remove mosquitto
|
||||||
ynh_secure_remove --file="/etc/mosquitto/conf.d"
|
ynh_secure_remove --file="/etc/mosquitto/conf.d"
|
||||||
|
|
|
@ -11,8 +11,6 @@ source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#Have to reload them as otherwise they are all the same
|
#Have to reload them as otherwise they are all the same
|
||||||
#backup_OS=$(ynh_app_setting_get --app="$app" --key=OS)
|
|
||||||
#backup_mach=$(ynh_app_setting_get --app="$app" --key=mach)
|
|
||||||
current_os=`lowercase \`uname -s\``
|
current_os=`lowercase \`uname -s\``
|
||||||
current_mach=`uname -m`
|
current_mach=`uname -m`
|
||||||
|
|
||||||
|
@ -23,9 +21,9 @@ current_mach=`uname -m`
|
||||||
#on the same system type. If we are restoring on another system type it won't work and in that
|
#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.
|
#case we must go through a reinstall process.
|
||||||
test "$OS" = "$current_os" \
|
test "$OS" = "$current_os" \
|
||||||
|| ynh_die --message="Cannot restore : previous OS is $backup_OS, current OS is $current_os, please reinstall"
|
|| ynh_die --message="Cannot restore : previous OS is $OS, current OS is $current_os, please reinstall"
|
||||||
test "$mach" = "$current_mach" \
|
test "$mach" = "$current_mach" \
|
||||||
|| ynh_die --message="Cannot restore : previous machine type is $backup_mach, current machine type is $current_mach, please reinstall"
|
|| ynh_die --message="Cannot restore : previous machine type is $mach, current machine type is $current_mach, please reinstall"
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=OS --value="$OS"
|
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=mach --value="$mach"
|
||||||
|
@ -69,7 +67,7 @@ chown -R "$app":"$app" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET MOSQUITTO SETTINGS
|
# SET MOSQUITTO SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
if [ ! -z "$mqtt_domain" ]; then
|
if [ "$domain" != "$mqtt_domain" ]; then
|
||||||
ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5
|
ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5
|
||||||
|
|
||||||
#Installing packages
|
#Installing packages
|
||||||
|
@ -92,7 +90,7 @@ systemctl enable "$app".service --quiet
|
||||||
ynh_script_progression --message="Integrating 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"
|
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -103,7 +101,7 @@ 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
|
#Restarting mosquitto to take changes into account
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
|
|
@ -57,34 +57,34 @@ if [ -z "$api_path" ]; then
|
||||||
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
|
fi
|
||||||
|
|
||||||
#Need to be kept for backward compatibility : previous version did not have settings stored and
|
#Previous version did not have settings stored and
|
||||||
#variable may not be bound.
|
#variable may not be bound.
|
||||||
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
||||||
if [[ -z "$mqtt_domain" ]]; then
|
if [[ -z "$mqtt_domain" ]]; then
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain"
|
ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$domain"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Port to listen for MQTT internal
|
#Port to listen for MQTT internal
|
||||||
#first we read from manifest to ensure variable is bound
|
#first we read from manifest to ensure variable is bound
|
||||||
mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port)
|
#mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port)
|
||||||
#then we store the setting in the manifest so it is automatically loaded for other scritps
|
#then we store the setting in the manifest so it is automatically loaded for other scritps
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
#ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
||||||
#then if a domain has been provided (manually for example to install mosquitto afterward), we assign a port in case it is empty.
|
#then if a domain has been provided (manually for example to install mosquitto afterward), we assign a port in case it is empty.
|
||||||
if [[ -z "$mqtt_port" && ! -z "$mqtt_domain" ]]; then
|
#if [[ -z "$mqtt_port" && ! -z "$mqtt_domain" ]]; then
|
||||||
mqtt_port=$(ynh_find_port --port="$default_mqtt_port")
|
# mqtt_port=$(ynh_find_port --port="$default_mqtt_port")
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
# ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
#Port to listen for MQTT websocket
|
#Port to listen for MQTT websocket
|
||||||
#first we read from manifest to ensure variable is bound
|
#first we read from manifest to ensure variable is bound
|
||||||
mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port)
|
#mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port)
|
||||||
#then we store the setting in the manifest so it is automatically loaded for other scritps
|
#then we store the setting in the manifest so it is automatically loaded for other scritps
|
||||||
ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port"
|
#ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port"
|
||||||
#then if a domain has been provided (manually for example to install mosquitto afterward), we assign a port in case it is empty.
|
#then if a domain has been provided (manually for example to install mosquitto afterward), we assign a port in case it is empty.
|
||||||
if [[ -z "$mqtt_websocket_port" && ! -z "$mqtt_domain" ]]; then
|
#if [[ -z "$mqtt_websocket_port" && ! -z "$mqtt_domain" ]]; then
|
||||||
mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_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"
|
# ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
# Create the permission "domoticz_API" only if it doesn't exist.
|
# Create the permission "domoticz_API" only if it doesn't exist.
|
||||||
#if ! ynh_permission_exists --permission="domoticz_API"
|
#if ! ynh_permission_exists --permission="domoticz_API"
|
||||||
|
@ -94,7 +94,7 @@ fi
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Create the permission "domoticz_MQTT" only if it doesn't exist.
|
# Create the permission "domoticz_MQTT" only if it doesn't exist.
|
||||||
if [ ! -z "$mqtt_domain" ]; then
|
if [ "$domain" != "$mqtt_domain" ]; then
|
||||||
if ! ynh_permission_exists --permission="domoticz_MQTT"
|
if ! ynh_permission_exists --permission="domoticz_MQTT"
|
||||||
then
|
then
|
||||||
# API Authorization with dedicated URL
|
# API Authorization with dedicated URL
|
||||||
|
@ -145,7 +145,7 @@ chown -R "$app":"$app" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET MOSQUITTO SETTINGS
|
# SET MOSQUITTO SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
if [ ! -z "$mqtt_domain" ]; then
|
if [ "$domain" != "$mqtt_domain" ]; then
|
||||||
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
ynh_script_progression --message="Setting up mosquitto..." --weight=5
|
||||||
|
|
||||||
#Installing packages
|
#Installing packages
|
||||||
|
@ -172,7 +172,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading NGINX web server 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"
|
[[ "$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
|
#Set Hook for nginx domain
|
||||||
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
||||||
|
@ -233,7 +233,7 @@ ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed logi
|
||||||
ynh_script_progression --message="Integrating 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"
|
[[ "$domain" != "$mqtt_domain" ]] && yunohost service add mosquitto --description="Serveur MQTT pour domoticz" --log="/var/log/mosquitto/mosquitto.log"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -244,7 +244,7 @@ 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
|
#Restarting mosquitto to take changes from /etc/mosquitto/conf.d/*.conf into account
|
||||||
[[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
[[ "$domain" != "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
68
tests.toml
68
tests.toml
|
@ -7,37 +7,37 @@ test_format = 1.0
|
||||||
test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
|
test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
|
||||||
|
|
||||||
|
|
||||||
#[With_Mosquitto_upgrade_with_mosquitto]
|
[With_Mosquitto_upgrade_with_mosquitto]
|
||||||
# preinstall = """
|
preinstall = """
|
||||||
# set -euxo pipefail
|
set -euxo pipefail
|
||||||
# yunohost domain add mqtt.domain.tld
|
yunohost domain add mqtt.domain.tld
|
||||||
# """
|
"""
|
||||||
# preupgrade = """
|
preupgrade = """
|
||||||
# set -euxo pipefail
|
set -euxo pipefail
|
||||||
# yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
|
yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
|
||||||
# """
|
"""
|
||||||
#
|
|
||||||
# args.mqtt_domain="mqtt.domain.tld"
|
args.mqtt_domain="mqtt.domain.tld"
|
||||||
#
|
|
||||||
# exclude = ["package_linter"]
|
exclude = ["package_linter"]
|
||||||
#
|
|
||||||
# test_upgrade_from.27311ad.name = "2022.2 with mosquitto"
|
test_upgrade_from.27311ad.name = "2022.2 with mosquitto"
|
||||||
# test_upgrade_from.27311ad.args.mqtt_domain="mqtt.domain.tld"
|
test_upgrade_from.27311ad.args.mqtt_domain="mqtt.domain.tld"
|
||||||
#
|
|
||||||
#
|
|
||||||
#[With_Mosquitto_upgrade_without_mosquitto]
|
[With_Mosquitto_upgrade_without_mosquitto]
|
||||||
# preinstall = """
|
preinstall = """
|
||||||
# set -euxo pipefail
|
set -euxo pipefail
|
||||||
# yunohost domain add mqtt.domain.tld
|
yunohost domain add mqtt.domain.tld
|
||||||
# """
|
"""
|
||||||
#
|
|
||||||
# preupgrade = """
|
preupgrade = """
|
||||||
# set -euxo pipefail
|
set -euxo pipefail
|
||||||
# yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
|
yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld
|
||||||
# """
|
"""
|
||||||
# args.mqtt_domain="mqtt.domain.tld"
|
args.mqtt_domain="mqtt.domain.tld"
|
||||||
#
|
|
||||||
# exclude = ["package_linter", "install.private", "install.multi", "backup_restore", "change_url"]
|
exclude = ["package_linter", "install.private", "install.multi", "backup_restore", "change_url"]
|
||||||
#
|
|
||||||
# test_upgrade_from.27311ad.name = "2022.2 without mosquitto"
|
test_upgrade_from.27311ad.name = "2022.2 without mosquitto"
|
||||||
# test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
|
test_upgrade_from.27311ad.args.mqtt_domain="sub.domain.tld"
|
Loading…
Reference in a new issue