mirror of
https://github.com/YunoHost-Apps/scrutiny_ynh.git
synced 2024-09-03 20:16:24 +02:00
71 lines
2.5 KiB
Bash
71 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Stopping $app's systemd service..."
|
|
|
|
ynh_systemctl --service="influxdb" --action="stop"
|
|
ynh_systemctl --service="scrutiny-web-server.service" --action="stop" --log_path="/var/log/$app/web-server.log"
|
|
if [ $collector -eq 1 ]
|
|
then
|
|
ynh_systemctl --service="scrutiny-collector.timer" --action="stop" --log_path="/var/log/$app/collector.log"
|
|
fi
|
|
|
|
#=================================================
|
|
# MODIFY URL IN NGINX CONF
|
|
#=================================================
|
|
ynh_script_progression "Updating NGINX web server configuration..."
|
|
|
|
ynh_config_change_url_nginx
|
|
|
|
#=================================================
|
|
# SPECIFIC MODIFICATIONS
|
|
#=================================================
|
|
# in the change_url context, variables called new_domain, new_path, old_domain, old_path will be available, as well as change_domain and change_path equal to 0 (false) or 1 (true) depending if the domain / path changed
|
|
#=================================================
|
|
|
|
if [ "$old_path" != "$new_path" ]
|
|
then
|
|
# Update scrutiny.yaml
|
|
if [ "${new_path}" == "/" ]
|
|
then
|
|
new_base_path=""
|
|
else
|
|
new_base_path="\\${new_path}"
|
|
fi
|
|
key="basepath"
|
|
new_value="'$new_base_path'"
|
|
sed --regexp-extended "s/^(\s*${key}:\s*).*/\1${new_value}/" --in-place "$install_dir/config/scrutiny.yaml"
|
|
ynh_store_file_checksum "$install_dir/config/scrutiny.yaml"
|
|
|
|
# Update collector.yaml
|
|
port=$(ynh_app_setting_get --key=port)
|
|
key="endpoint"
|
|
new_value="'http:\/\/127.0.0.1:${port}${new_base_path}\/'"
|
|
sed --regexp-extended "s/^(\s*${key}:\s*).*/\1${new_value}/" --in-place "$install_dir/config/collector.yaml"
|
|
ynh_store_file_checksum "$install_dir/config/collector.yaml"
|
|
fi
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
systemctl daemon-reload
|
|
|
|
ynh_systemctl --service="influxdb" --action="start"
|
|
ynh_systemctl --service="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
|
|
if [ $collector -eq 1 ]
|
|
then
|
|
ynh_systemctl --service="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
|
|
fi
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Change of URL completed for $app"
|