mirror of
https://github.com/YunoHost-Apps/domoticz_ynh.git
synced 2024-09-03 18:26:17 +02:00
Add hooks for conf_regen
This commit is contained in:
parent
ef9fdf5bc8
commit
fb8fd3cd86
6 changed files with 45 additions and 0 deletions
|
@ -70,6 +70,7 @@ 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
|
||||
|
||||
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -169,6 +169,7 @@ if [ ! -z "$mqtt_domain" ]; then
|
|||
ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app"
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -176,6 +177,10 @@ 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"
|
||||
|
||||
#Set Hook for nginx domain
|
||||
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
||||
yunohost tools regen-conf nginx
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
|
|
@ -76,6 +76,11 @@ ynh_secure_remove --file="$final_path"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
#remove hook for mqtt nginx
|
||||
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
||||
yunohost tools regen-conf postfix
|
||||
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf"
|
||||
|
||||
|
|
|
@ -151,6 +151,15 @@ 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/"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
|
||||
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
||||
yunohost tools regen-conf postfix
|
||||
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -224,6 +224,9 @@ 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"
|
||||
|
||||
#Set Hook for nginx domain
|
||||
cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/
|
||||
yunohost tools regen-conf nginx
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
|
22
sources/hooks/conf_regen/95-nginx_domoticz
Normal file
22
sources/hooks/conf_regen/95-nginx_domoticz
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
action=$1
|
||||
pending_dir=$4
|
||||
nginx_conf=$pending_dir/../nginx/etc/nginx
|
||||
|
||||
[[ $action == "pre" ]] || exit 0
|
||||
|
||||
#Il ne peut y avoir qu'une seule instance de l'apps sur un système, donc pas à besoin de regarder quelle id utiliser
|
||||
mqtt_port=$(yunohost app setting domoticz mqtt_websocket_port)
|
||||
mqtt_domain=$(yunohost app setting domoticz mqtt_domain)
|
||||
domain=$(yunohost app setting domoticz domain)
|
||||
nginx_mqtt="$nginx_conf"/conf.d/"$mqtt_domain".conf
|
||||
|
||||
[[ ! -z $mqtt_domain ]] || exit 0
|
||||
[[ -e $nginx_mqtt ]] || exit 0
|
||||
|
||||
|
||||
if [[ "$mqtt_domain" != "domain" ]]; then
|
||||
#single quote pour ne pas étendre les variables du fichier de config nginx et doubles quote pour les variables à étendre
|
||||
sed -i '/map $http_upgrade $connection_upgrade {/i upstream '"${mqtt_domain}"' {\n server localhost:'"${mqtt_port}"';\n}\n' $nginx_mqtt
|
||||
fi
|
Loading…
Add table
Reference in a new issue