1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00
sogo_ynh/scripts/restore

72 lines
2.6 KiB
Text
Raw Normal View History

2016-03-18 18:38:54 +01:00
#!/bin/bash
2018-08-14 22:18:22 +02:00
#=================================================
# GENERIC START
#=================================================
2022-01-15 10:05:56 +01:00
# IMPORT GENERIC HELPERS
#=================================================
2016-03-18 18:38:54 +01:00
2022-01-15 10:05:56 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-11-17 23:55:57 +01:00
source ../settings/scripts/_common.sh
2018-08-14 22:18:22 +02:00
source /usr/share/yunohost/helpers
2016-03-18 18:38:54 +01:00
2022-01-15 10:05:56 +01:00
#=================================================
2018-08-14 22:18:22 +02:00
# RESTORE THE MYSQL DATABASE
2022-01-15 10:05:56 +01:00
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
2024-01-30 23:33:35 +01:00
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
2018-08-14 22:18:22 +02:00
# Enable stunnel at startup
ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
2018-08-14 22:18:22 +02:00
2022-01-15 13:19:43 +01:00
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/$app"
2024-01-30 23:33:35 +01:00
chown -R "$app:$app" "/etc/$app"
chmod -R 750 "/etc/$app"
2022-01-15 13:19:43 +01:00
2024-01-30 23:33:35 +01:00
ynh_backup --src_path="/etc/stunnel/$app.conf"
ynh_restore_file --origin_path="/etc/cron.d/$app"
2022-01-15 10:05:56 +01:00
2024-01-30 23:33:35 +01:00
ynh_restore_file --origin_path="/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
chmod -R 750 "/var/log/$app"
2018-08-14 22:18:22 +02:00
2022-01-15 13:19:43 +01:00
#=================================================
2024-01-30 23:33:35 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2022-01-15 13:19:43 +01:00
#=================================================
2024-01-30 23:33:35 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-01-15 13:19:43 +01:00
2024-01-30 23:33:35 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2018-08-14 22:18:22 +02:00
2024-01-30 23:33:35 +01:00
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
2022-01-15 10:05:56 +01:00
2024-01-30 23:33:35 +01:00
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
2022-01-15 10:05:56 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
2024-01-30 23:33:35 +01:00
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
ynh_systemd_action --service_name="stunnel4" --action="restart" --log_path="systemd"
2022-01-15 10:05:56 +01:00
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2024-01-30 23:33:35 +01:00
ynh_systemd_action --service_name="nginx" --action=reload
2022-01-15 10:05:56 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-05-24 00:32:03 +02:00
ynh_script_progression --message="Restoration completed for $app" --last