2015-11-18 00:28:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2017-09-05 00:25:58 +02:00
|
|
|
# GENERIC START
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-11-08 13:33:28 +01:00
|
|
|
|
2021-05-16 16:48:58 +02:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-04-24 20:16:33 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2018-05-20 20:55:15 +02:00
|
|
|
#=================================================
|
|
|
|
# ACTIVATE MAINTENANCE MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_maintenance_mode_ON
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..."
|
2015-11-18 00:28:42 +01:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2017-03-19 19:16:10 +01:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2017-03-19 19:16:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-23 08:54:56 +02:00
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2022-06-23 08:54:56 +02:00
|
|
|
ynh_script_progression --message="Restoring the NGINX configuration..."
|
2017-03-19 19:16:10 +01:00
|
|
|
|
2022-06-23 08:54:56 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-03-19 19:16:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-23 08:54:56 +02:00
|
|
|
# RESTORE VARIOUS FILES
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2022-06-23 08:54:56 +02:00
|
|
|
ynh_script_progression --message="Restoring various files..."
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
2015-11-18 00:28:42 +01:00
|
|
|
|
2019-01-18 19:56:43 +01:00
|
|
|
# Making log a symbolic link to /var/log
|
2017-09-05 00:25:58 +02:00
|
|
|
mkdir -p /var/log/$app/
|
|
|
|
touch /var/log/$app/production.log
|
2017-09-08 13:10:22 +02:00
|
|
|
chown $app -R /var/log/$app
|
2017-03-19 19:16:10 +01:00
|
|
|
|
2020-12-09 08:40:39 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# RESTORE SYSTEMD
|
2020-12-09 08:40:39 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
ynh_script_progression --message="Restoring the systemd configuration..."
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
|
|
systemctl enable $app.service --quiet
|
2020-12-09 08:40:39 +01:00
|
|
|
|
2022-06-23 08:54:56 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the logrotate configuration..."
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
2021-05-16 16:48:58 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
2022-06-23 08:54:56 +02:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
yunohost service add $app --log="$install_dir/log/production.log"
|
2020-12-09 08:40:39 +01:00
|
|
|
|
2017-04-19 19:23:23 +02:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2017-04-19 19:23:23 +02:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
|
|
|
|
|
|
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# GENERIC FINALIZATION
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-10-05 22:02:46 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
|
2016-08-05 16:59:55 +02:00
|
|
|
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2017-05-24 16:48:26 +02:00
|
|
|
|
2018-05-20 20:55:15 +02:00
|
|
|
#=================================================
|
|
|
|
# DEACTIVE MAINTENANCE MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_maintenance_mode_OFF
|
|
|
|
|
2019-01-30 16:19:40 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-12 15:30:00 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|