1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/teampass_ynh.git synced 2024-09-03 20:26:37 +02:00
teampass_ynh/scripts/restore

131 lines
4 KiB
Text
Raw Normal View History

#!/bin/bash
2015-12-18 14:11:35 +01:00
#=================================================
2018-05-22 20:01:55 +02:00
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-12-14 16:02:43 +01:00
if [ ! -e _common.sh ]; then
2018-05-22 20:01:55 +02:00
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
2016-12-14 16:02:43 +01:00
source /usr/share/yunohost/helpers
2018-05-22 20:01:55 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
2016-12-14 16:02:43 +01:00
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
2016-12-14 16:02:43 +01:00
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2018-05-22 20:01:55 +02:00
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
2018-05-22 20:01:55 +02:00
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_ON
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE OF THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE OF THE MAIN DIR OF THE APP
#=================================================
2016-12-14 16:02:43 +01:00
ynh_restore_file "$final_path"
#=================================================
# RESTORE OF THE SQL BDD
#=================================================
2016-12-14 16:02:43 +01:00
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
2015-12-18 14:11:35 +01:00
ynh_system_user_create $app # Recreate the dedicated user, if not exist
#=================================================
# RESTORE USER RIGHTS
#=================================================
2016-12-14 16:02:43 +01:00
# Les fichiers appartiennent à root
2018-05-22 20:01:55 +02:00
chown -R root: $final_path
# Sauf les dossiers files et upload
2018-05-22 20:01:55 +02:00
chown -R $app: $final_path/files $final_path/upload
#=================================================
# RESTORE OF THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE THE SK.PHP FILE
#=================================================
2018-05-22 20:01:55 +02:00
ynh_restore_file "/etc/$app/sk.php"
chown -R root:$app "/etc/$app/sk.php"
#=================================================
# RESTORE CRON FILE
#=================================================
2018-05-22 20:01:55 +02:00
ynh_restore_file "/etc/cron.d/$app"
2016-12-14 16:02:43 +01:00
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
2015-12-18 14:11:35 +01:00
2018-05-22 20:01:55 +02:00
ynh_system_reload php5-fpm
ynh_system_reload nginx
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_OFF
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/teampass_ynh"
ynh_send_readme_to_admin "$message" "root"