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

Improve bash syntax

This commit is contained in:
Krakinou 2024-01-31 22:51:02 +01:00
parent 94b607f3d4
commit f5ab76d6bf
5 changed files with 18 additions and 18 deletions

View file

@ -26,8 +26,8 @@ ynh_backup --src_path="$install_dir"
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$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"
[[ "$domain" != "$mqtt_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

View file

@ -74,14 +74,14 @@ if [ "$domain" != "$mqtt_domain" ]; then
ynh_script_progression --message="Setting up mosquitto..." --weight=5 ynh_script_progression --message="Setting up mosquitto..." --weight=5
#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
#Setting up user&pwd for mqtt access #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_user --value=$(ynh_string_random --length=8)
ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) 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" 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" 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" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app"
else else
@ -95,13 +95,13 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
[[ "$domain" != "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf" [[ "$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/
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_config --template="api_nginx.conf" --destination="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ynh_add_config --template="api_nginx.conf" --destination="/etc/nginx/conf.d/${domain}.d/api_${app}.conf"
ynh_add_nginx_config ynh_add_nginx_config

View file

@ -20,7 +20,7 @@ if [ "$domain" != "$mqtt_domain" ]; then
yunohost service remove mosquitto yunohost service remove mosquitto
ynh_secure_remove --file="/etc/mosquitto/conf.d" ynh_secure_remove --file="/etc/mosquitto/conf.d"
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf" ynh_secure_remove --file="/etc/nginx/conf.d/${mqtt_domain}.d/mqtt_${app}.conf"
yunohost tools regen-conf postfix yunohost tools regen-conf postfix
ynh_secure_remove --file="/var/log/mosquitto" ynh_secure_remove --file="/var/log/mosquitto"
fi fi
@ -35,7 +35,7 @@ fi
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
ynh_secure_remove --file="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ynh_secure_remove --file="/etc/nginx/conf.d/${domain}.d/api_${app}.conf"
ynh_remove_nginx_config ynh_remove_nginx_config
ynh_remove_logrotate ynh_remove_logrotate

View file

@ -36,8 +36,8 @@ ynh_app_setting_set --app="$app" --key=mach --value="$current_mach"
ynh_script_progression --message="Restoring the NGINX web server configuration..." 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/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/${domain}.d/api_${app}.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory ynh_restore_file --origin_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_${app}.conf" --not_mandatory
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER

View file

@ -109,16 +109,16 @@ if [ "$domain" != "$mqtt_domain" ]; then
ynh_script_progression --message="Setting up mosquitto..." --weight=5 ynh_script_progression --message="Setting up mosquitto..." --weight=5
#Setting up conf file for access #Setting up conf file for access
if [ ! -f "/etc/mosquitto/conf.d/"$app"_mosquitto.conf" ] if [ ! -f "/etc/mosquitto/conf.d/${app}_mosquitto.conf" ]
then then
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
#Setting up user&pwd for mqtt access #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_user --value=$(ynh_string_random --length=8)
ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) 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" 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" 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" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app"
fi fi
@ -132,17 +132,17 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." ynh_script_progression --message="Upgrading NGINX web server configuration..."
[[ "$domain" != "$mqtt_domain" ]] && ynh_add_config --template="../conf/mqtt_nginx.conf" --destination="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf" [[ "$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/
# Create a dedicated NGINX config # Create a dedicated NGINX config
if [[ ! -f "/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ]] if [[ ! -f "/etc/nginx/conf.d/${domain}.d/api_${app}.conf" ]]
then then
ynh_print_warn --message="The nginx conf file will now be splitted between standard and api related path" ynh_print_warn --message="The nginx conf file will now be splitted between standard and api related path"
ynh_print_warn --message="Report any manual changes on the new /etc/nginx/conf.d/$domain.d/api_$app.conf file for json command to keep working" ynh_print_warn --message="Report any manual changes on the new /etc/nginx/conf.d/$domain.d/api_$app.conf file for json command to keep working"
ynh_add_config --template="api_nginx.conf" --destination="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ynh_add_config --template="api_nginx.conf" --destination="/etc/nginx/conf.d/${domain}.d/api_${app}.conf"
fi fi
ynh_add_nginx_config ynh_add_nginx_config