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

85 lines
3 KiB
Text
Raw Normal View History

2018-04-15 12:49:57 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-02-09 00:51:15 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2019-07-14 18:42:38 +02:00
source ../settings/scripts/_common.sh
2018-04-15 12:49:57 +02:00
source /usr/share/yunohost/helpers
#=================================================
2023-05-22 23:31:46 +02:00
# RESTORE THE APP MAIN DIR
2018-04-15 12:49:57 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2018-04-15 12:49:57 +02:00
2023-05-22 23:31:46 +02:00
ynh_restore_file --origin_path="$install_dir"
2020-04-11 14:18:16 +02:00
2023-05-22 23:31:46 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2018-04-15 12:49:57 +02:00
2023-05-22 23:31:46 +02:00
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
2018-04-15 12:49:57 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
# RESTORE THE DATA DIRECTORY
2018-04-15 12:49:57 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
ynh_script_progression --message="Restoring the data directory..." --weight=1
2018-04-15 12:49:57 +02:00
2023-05-22 23:31:46 +02:00
ynh_restore_file --origin_path="$data_dir" --not_mandatory
2018-04-15 12:49:57 +02:00
2023-05-22 23:31:46 +02:00
# (Same as for install dir)
chown -R $app:www-data "$data_dir"
2018-04-15 12:49:57 +02:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
2020-12-13 21:40:17 +01:00
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
2022-06-15 01:48:45 +02:00
2020-04-11 14:18:16 +02:00
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
2020-12-13 21:40:17 +01:00
2023-05-22 23:31:46 +02:00
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
2018-04-15 12:49:57 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
# RESTORE SYSTEM CONFIGURATIONS
2018-04-15 12:49:57 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
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"
2018-04-15 12:49:57 +02:00
2022-02-09 00:51:15 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
2020-12-13 21:40:17 +01:00
systemctl enable $app.service --quiet
2018-04-15 12:49:57 +02:00
2022-02-09 00:51:15 +01:00
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2023-05-22 23:31:46 +02:00
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
2022-02-09 00:51:15 +01:00
2018-04-15 12:49:57 +02:00
#=================================================
2020-12-13 21:40:17 +01:00
# START SYSTEMD SERVICE
2018-04-15 12:49:57 +02:00
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2018-04-15 12:49:57 +02:00
2022-02-09 00:51:15 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
2018-04-15 12:49:57 +02:00
2020-12-13 21:40:17 +01:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2020-05-03 14:03:03 +02:00
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Restoration completed for $app" --last