1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00
monitorix_ynh/scripts/change_url
2020-11-17 23:37:38 +01:00

62 lines
1.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
# Retrive arguments
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
old_domain=$YNH_APP_OLD_DOMAIN
domain=$YNH_APP_NEW_DOMAIN
port=$(ynh_app_setting_get --app $app --key http_port)
nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
dbuser=$app
dbname=$app
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Updating nginx configuration..."
# Update nginx config
if [ "$old_domain" != "$domain" ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
config_nginx
ynh_script_progression --message="Updating monitorix configuration..."
# Update monitorix configuration
config_monitorix
ynh_script_progression --message="Restarting monitorix services..." --weight=3
# Reload monitorix
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
ynh_script_progression --message="Change of URL completed for $app" --last