2017-06-17 17:28:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Get multi-instances specific variables
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Set app specific variables
|
|
|
|
dbname=$app
|
|
|
|
dbuser=$app
|
|
|
|
|
|
|
|
# Retrieve old app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
|
|
|
|
|
|
|
|
|
|
# Source local utils
|
|
|
|
if [ ! -e _common.sh ]; then
|
|
|
|
# Fetch the local helpers files, because unavail to restore script
|
|
|
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
|
|
|
sudo chmod a+rx _common.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
|
|
|
|
|
2018-11-25 17:11:09 +01:00
|
|
|
ynh_webpath_register $app $domain $path
|
2017-06-17 17:28:57 +02:00
|
|
|
|
|
|
|
test -d $INSTALL_DIR && ynh_die \
|
|
|
|
"The destination directory '$INSTALL_DIR' already exists.\
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
|
|
|
|
test -f $nginx_conf_path && ynh_die \
|
|
|
|
"The NGINX configuration already exists at '${nginx_conf_path}'.
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
|
|
|
|
test -f $supervisor_conf_path && ynh_die \
|
|
|
|
"The Supervisor configuration already exists at '${supervisor_conf_path}'.
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
|
|
|
|
test -f $gunicorn_conf_path && ynh_die \
|
|
|
|
"The Gunicorn configuration already exists at '${gunicorn_conf_path}'.
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
|
2017-06-19 09:35:17 +02:00
|
|
|
install_apt_dependencies
|
2017-06-18 17:14:35 +02:00
|
|
|
|
2017-06-19 09:35:17 +02:00
|
|
|
create_unix_user
|
2017-06-17 17:28:57 +02:00
|
|
|
|
|
|
|
# Restore the app files
|
|
|
|
sudo cp -a ./install_dir/. "$INSTALL_DIR"
|
|
|
|
|
|
|
|
# Create and restore the database
|
|
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
|
|
|
|
2017-06-19 09:35:17 +02:00
|
|
|
create_system_dirs
|
2017-06-17 17:28:57 +02:00
|
|
|
|
|
|
|
# Restore settings
|
|
|
|
sudo cp -a "conf/nginx.conf" "$nginx_conf_path"
|
|
|
|
sudo cp -a "conf/gunicorn.conf.py" "$gunicorn_conf_path"
|
|
|
|
sudo cp -a "conf/supervisor.conf" "$supervisor_conf_path"
|
2017-06-21 13:30:48 +02:00
|
|
|
sudo cp -a "conf/ihatemoney.cfg" "$ihatemoney_conf_path"
|
2017-06-17 17:28:57 +02:00
|
|
|
|
|
|
|
# Reload
|
|
|
|
sudo systemctl reload nginx
|
|
|
|
sudo systemctl restart supervisor
|
|
|
|
sudo supervisorctl restart budget
|