#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql # Enable stunnel at startup ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4 #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/$app" chown -R "$app:$app" "/etc/$app" chmod -R 750 "/etc/$app" ynh_restore_file --origin_path="/etc/stunnel/$app.conf" ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/var/log/$app" chown -R "$app:$app" "/var/log/$app" chmod -R 750 "/var/log/$app" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= 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" systemctl enable "$app.service" --quiet yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" ynh_systemd_action --service_name="stunnel4" --action="restart" --log_path="systemd" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name="nginx" --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last