2023-03-03 10:07:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2023-03-06 21:25:34 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-web-server.service"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.service"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.timer"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
2023-03-06 21:25:34 +01:00
|
|
|
ynh_restore_file --origin_path="/var/log/$app"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
|
|
|
|
2023-04-03 09:08:54 +02:00
|
|
|
systemctl daemon-reload
|
|
|
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name="influxdb" --action="enable"
|
2023-03-06 21:25:34 +01:00
|
|
|
ynh_systemd_action --service_name="influxdb" --action="start"
|
2023-04-03 09:08:54 +02:00
|
|
|
|
|
|
|
systemctl enable "/etc/systemd/system/scrutiny-web-server.service" --quiet
|
2023-04-03 11:59:03 +02:00
|
|
|
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log" --test_status="systemctl show scrutiny-web-server.service -p ActiveState --value | grep -v failed"
|
2023-03-07 22:33:13 +01:00
|
|
|
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
|
2023-04-03 09:08:54 +02:00
|
|
|
|
2023-03-07 22:33:13 +01:00
|
|
|
if [ $collector -eq 1 ]
|
|
|
|
then
|
2023-04-03 09:08:54 +02:00
|
|
|
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"
|
2023-03-06 21:25:34 +01:00
|
|
|
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable"
|
2023-03-07 22:33:13 +01:00
|
|
|
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
|
2023-03-06 21:25:34 +01:00
|
|
|
fi
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|