1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
limesurvey_ynh/scripts/restore
2018-03-14 03:32:18 +01:00

94 lines
3.1 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source ../settings/scripts/_common.sh
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
export app=$YNH_APP_INSTANCE_NAME
export domain=$(ynh_app_setting_get $app domain)
export path_url=$(ynh_app_setting_get $app path)
export admin=$(ynh_app_setting_get $app admin)
export final_path=$(ynh_app_setting_get $app final_path)
export is_public=$(ynh_app_setting_get $app is_public)
export prefix=$(ynh_app_setting_get $app prefix)
export db_name=$(ynh_app_setting_get $app db_name)
export db_user=$(ynh_app_setting_get $app db_user)
export db_pwd=$(ynh_app_setting_get $app mysqlpwd)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
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 "
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE OF THE SQL BDD
#=================================================
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RESTORE FILES
#=================================================
# Restore files
ynh_restore
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_system_user_create "$app" "$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
set_permissions
#=================================================
# SETUP SSOWAT
#=================================================
ynh_sso_access "/index.php?r=admin,/index.php?r=plugins,/scripts"
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_system_reload php5-fpm
ynh_system_reload nginx
#=================================================
# 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/leed_ynh"
ynh_send_readme_to_admin "$message" "$admin"