libreerp_ynh/scripts/restore

56 lines
1.5 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2017-05-18 23:28:18 +02:00
set -eu
# Import helpers
source /usr/share/yunohost/helpers
source ../settings/scripts/_future.sh
source ../settings/scripts/_common.sh
2018-12-14 03:36:58 +01:00
ynh_abort_if_errors
2017-05-18 23:28:18 +02:00
export app=$YNH_APP_INSTANCE_NAME
export domain=$(ynh_app_setting_get $app domain)
export app_version=$(ynh_app_setting_get $app app_version)
2017-05-18 23:28:18 +02:00
export oca=$(ynh_app_setting_get $app oca)
export port=$(ynh_app_setting_get $app port)
2018-12-14 03:36:58 +01:00
export port_chat=$(ynh_app_setting_get $app port_chat)
export db_name=$(ynh_app_setting_get $app db_name)
export db_pass=$(ynh_app_setting_get $app psqlpwd)
export final_path=$(ynh_app_setting_get $app final_path)
2018-12-14 20:26:59 +01:00
export conf_file=$(ynh_app_setting_get $app conf_file)
2017-05-18 23:28:18 +02:00
export is_public=0
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_webpath_available "$domain" "/"
#=================================================
# RESTORE THE APP BY MODIFYING THE SYSTEM
#=================================================
# Restore files
function restore_files () {
2018-12-14 03:36:58 +01:00
ynh_restore
chown -R $app:$app $final_path
chown $app:$app $conf_file
touch /var/log/$app.log
chown $app:$app /var/log/$app.log
2017-05-18 23:28:18 +02:00
}
# Restore database
function restore_database () {
2018-12-14 03:36:58 +01:00
su -c "psql $app" postgres < ./dump.sql
2017-05-18 23:28:18 +02:00
}
2018-12-14 03:36:58 +01:00
ynh_system_user_create $app $final_path
2017-05-18 23:28:18 +02:00
restore_files
2018-12-14 03:36:58 +01:00
install_dependencies
ynh_psql_test_if_first_run
ynh_psql_setup_db $db_name $db_name $db_pass
2017-05-18 23:28:18 +02:00
add_services
restore_database
ssowat_and_restart