1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00
mattermost_ynh/scripts/restore

101 lines
3.3 KiB
Text
Raw Normal View History

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
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
2022-06-22 11:09:45 +02:00
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
2017-09-11 12:05:16 +02:00
2021-01-11 23:46:48 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2017-09-11 12:05:16 +02:00
#=================================================
# 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-02-07 22:27:23 +01:00
ynh_restore_file --origin_path="$install_dir"
2017-09-11 12:05:16 +02:00
2023-02-07 22:27:23 +01: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
#=================================================
2021-09-16 11:39:20 +02:00
ynh_script_progression --message="Restoring the data directory..." --weight=4
2021-09-16 11:39:20 +02:00
ynh_restore_file --origin_path="$data_path" --not_mandatory
2021-09-16 11:39:20 +02:00
mkdir -p $data_path
2017-09-11 12:05:16 +02:00
2021-09-16 11:39:20 +02:00
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
2017-09-11 12:05:16 +02:00
2022-06-22 10:58:12 +02:00
#=================================================
# RESTORE THE DATABASE
#=================================================
ynh_script_progression --message="Restoring the database..." --weight=6
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
2017-09-11 12:05:16 +02:00
#=================================================
# RESTORE USER RIGHTS
#=================================================
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-09-11 12:05:16 +02:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE SYSTEMD
2017-09-11 12:05:16 +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
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
2021-01-11 23:46:48 +01:00
yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost"
2021-01-11 23:46:48 +01:00
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2017-09-11 12:05:16 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2017-10-12 08:08:53 +02:00
# RELOAD NGINX
2017-09-11 12:05:16 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
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