2017-09-11 12:05:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
2017-09-11 12:05:16 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-09-11 12:05:16 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=2
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-09-16 11:39:20 +02:00
|
|
|
|
2017-09-11 12:05:16 +02:00
|
|
|
#=================================================
|
2021-09-16 11:39:20 +02:00
|
|
|
# RESTORE THE DATA DIRECTORY
|
2018-01-29 06:45:24 +01:00
|
|
|
#=================================================
|
2021-09-16 11:39:20 +02:00
|
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=4
|
2018-01-29 06:45:24 +01:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
2018-01-29 06:45:24 +01:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
chown -R $app:www-data "$data_dir"
|
2017-09-11 12:05:16 +02:00
|
|
|
|
|
|
|
#=================================================
|
2023-09-11 21:36:20 +02:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2017-09-11 12:05:16 +02:00
|
|
|
#=================================================
|
2023-09-11 21:36:20 +02:00
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
2023-03-14 11:16:39 +01:00
|
|
|
#=================================================
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2023-03-14 11:16:39 +01:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
logs_path="/var/log/$app"
|
|
|
|
mkdir -p $logs_path
|
|
|
|
chown -R $app: $logs_path
|
2017-10-10 12:47:33 +02:00
|
|
|
|
2017-10-12 12:47:51 +02:00
|
|
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
2021-01-11 23:46:48 +01:00
|
|
|
systemctl enable $app.service --quiet
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
2017-10-12 14:51:54 +02:00
|
|
|
|
2017-09-11 12:05:16 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2023-09-11 21:36:20 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
2017-09-11 12:05:16 +02:00
|
|
|
#=================================================
|
2023-09-11 21:36:20 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost"
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2017-10-12 08:08:53 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
# END OF SCRIPT
|
2017-10-12 08:08:53 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|