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

137 lines
4.9 KiB
Text
Raw Normal View History

2018-02-06 14:33:23 +01:00
#!/bin/bash
2018-02-11 00:32:26 +01:00
#=================================================
# GENERIC START
#=================================================
2022-03-09 00:27:32 +01:00
# IMPORT GENERIC HELPERS
#=================================================
2018-02-11 00:32:26 +01:00
2022-03-09 00:27:32 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
2018-02-06 14:33:23 +01:00
source /usr/share/yunohost/helpers
2022-03-09 00:27:32 +01:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
2018-02-06 14:33:23 +01:00
ynh_abort_if_errors
2022-03-09 00:27:32 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
app=$YNH_APP_INSTANCE_NAME
2022-03-09 00:27:32 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
gollem_data_dir=$(ynh_app_setting_get --app=$app --key=gollem_data_dir)
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
#=================================================
2018-02-06 14:33:23 +01:00
# CHECK IF THE APP CAN BE RESTORED
2022-03-09 00:27:32 +01:00
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
2018-02-06 14:33:23 +01:00
test ! -d $final_path \
2022-03-09 00:27:32 +01:00
|| ynh_die --message="There is already a directory: $final_path "
2018-02-06 14:33:23 +01:00
2018-02-11 00:32:26 +01:00
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
2022-03-09 00:27:32 +01:00
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
2018-02-11 00:32:26 +01:00
2022-03-09 00:27:32 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
2018-02-06 14:33:23 +01:00
# Create the dedicated user (if not existing)
2022-03-09 00:27:32 +01:00
ynh_system_user_create --username=$app --home_dir="$final_path"
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$gollem_data_dir"
2022-03-09 20:12:38 +01:00
mkdir -p $gollem_data_dir
2022-03-09 00:27:32 +01:00
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
install_dependance
#=================================================
2018-02-06 14:33:23 +01:00
# RESTORE THE MYSQL DATABASE
2022-03-09 00:27:32 +01:00
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
2018-02-06 14:33:23 +01:00
2018-02-11 00:32:26 +01:00
#=================================================
2022-03-09 00:27:32 +01:00
# RESTORE VARIOUS FILES
2018-02-11 00:32:26 +01:00
#=================================================
2022-03-09 00:27:32 +01:00
ynh_script_progression --message="Restoring various files..."
2018-02-11 00:32:26 +01:00
2018-02-06 14:33:23 +01:00
set_permission
2022-03-09 00:27:32 +01:00
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
2019-11-04 20:30:33 +01:00
ynh_use_logrotate $final_path/horde --nonappend --specific_user www-data/horde
ynh_use_logrotate $final_path/horde/services --append --specific_user www-data/horde
ynh_use_logrotate $final_path/horde/services/portal --append --specific_user www-data/horde
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2022-03-09 00:27:32 +01:00
ynh_script_progression --message="Restoration completed for $app"