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)
|
2018-12-14 19:24:55 +01:00
|
|
|
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)
|
2018-12-14 20:21:31 +01:00
|
|
|
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
|
2022-02-13 19:55:00 +01:00
|
|
|
export bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME-bin"
|
2018-12-16 19:41:40 +01:00
|
|
|
if [ "$app_version" = "9" ]; then
|
2022-02-13 19:55:00 +01:00
|
|
|
bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py"
|
2018-12-16 19:41:40 +01:00
|
|
|
fi
|
|
|
|
if [ "$app_version" = "8" ]; then
|
2022-02-13 19:55:00 +01:00
|
|
|
bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py"
|
2018-12-16 19:41:40 +01:00
|
|
|
fi
|
2017-05-18 23:28:18 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
2018-12-14 20:21:31 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|