diff --git a/manifest.toml b/manifest.toml index bb6d906..2531e0a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -52,8 +52,7 @@ ram.runtime = "50M" main.show_tile = true main.protected= true main.allowed = "admins" - #api.url = "__DOMAIN____PATH__/api/" # __PATH__ in not handled by yunohost for the api in manifest.toml - api.url = "re:__DOMAIN__/.*api/.*" + api.url = "/api" api.auth_header = false api.show_tile = false api.protected= true diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..c5594df --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,81 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name="influxdb" --action="stop" +ynh_systemd_action --service_name="scrutiny-web-server.service" --action="stop" --log_path="/var/log/$app/web-server.log" +if [ $collector -eq 1 ] +then + ynh_systemd_action --service_name="scrutiny-collector.timer" --action="stop" --log_path="/var/log/$app/collector.log" +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +ynh_change_url_nginx_config + +#================================================= +# 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 --file="$install_dir/config/scrutiny.yaml" + + # Update collector.yaml + port=$(ynh_app_setting_get --app=$app --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 --file="$install_dir/config/collector.yaml" +fi + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name="influxdb" --action="start" +ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log" +if [ $collector -eq 1 ] +then + systemctl daemon-reload + ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/collector.log" + ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log" +fi + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index d6b46d2..1b5f4e5 100755 --- a/scripts/install +++ b/scripts/install @@ -44,7 +44,7 @@ yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service" if [ $collector -eq 1 ] then - yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" + yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" --test_status="systemctl show scrutiny-collector.service -p ActiveState --value | grep -v failed" fi # Use logrotate to manage application logfile(s) diff --git a/scripts/restore b/scripts/restore index 056c22c..9e1dd5e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.timer" yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log" if [ $collector -eq 1 ] then - yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" + yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" --test_status="systemctl show scrutiny-collector.service -p ActiveState --value | grep -v failed" fi ynh_restore_file --origin_path="/etc/logrotate.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 0faac90..da81cdb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,7 +67,7 @@ yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service" if [ $collector -eq 1 ] then - yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" + yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" --test_status="systemctl show scrutiny-collector.service -p ActiveState --value | grep -v failed" fi ynh_use_logrotate --specific_user="$app" --non-append diff --git a/tests.toml b/tests.toml index de10639..bec3677 100644 --- a/tests.toml +++ b/tests.toml @@ -18,8 +18,4 @@ test_format = 1.0 # Commits to test upgrade from # ------------------------------- - - -[some_additional_testsuite] - - args.collector = false +