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

68 lines
1.7 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
ynh_trap_on
export app=$YNH_APP_INSTANCE_NAME
export domain=$(ynh_app_setting_get $app domain)
export odoo_version=$(ynh_app_setting_get $app odoo_version)
export oca=$(ynh_app_setting_get $app oca)
export port=$(ynh_app_setting_get $app port)
export is_public=0
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_check_var "$app" "app name not set"
ynh_webpath_available "$domain" "/"
check_odoo_version
define_paths
define_is_master
define_port
define_dbpass restore
#=================================================
# RESTORE THE APP BY MODIFYING THE SYSTEM
#=================================================
# Restore files
function restore_files () {
if [ "$is_master" = true ]; then
ynh_restore
2017-12-23 03:17:56 +01:00
chown -R odoo:odoo /var/lib/odoo/
2018-09-19 15:53:06 +02:00
chown postgres:postgres /etc/postgresql/9.*/main/pg_hba.conf
2017-05-18 23:28:18 +02:00
else
# If odoo is already setup we just restore nginx and add some missing
# modules. Other files are already on system, and we don't want to
# erase it
# Configure Nginx and reload
ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# TODO Restore plugin/addons
fi
}
# Restore database
function restore_database () {
# Restore database
database=${domain//./-}
su -c "createdb -O $APPNAME $database" - postgres
su -c "psql $database" postgres < ./dump.sql
}
ynh_save_args is_master port
install_dependencies
restore_files
create_general_db
add_services
restore_database
ssowat_and_restart