2017-06-17 17:28:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Source app helpers
|
2020-07-01 17:14:15 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-06-17 17:28:57 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2020-07-01 17:14:15 +02:00
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-06-17 17:28:57 +02:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
|
|
|
test -d $INSTALL_DIR && ynh_die \
|
|
|
|
"The destination directory '$INSTALL_DIR' already exists.\
|
|
|
|
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
|
|
|
|
2018-12-18 20:05:05 +01:00
|
|
|
create_system_dirs
|
|
|
|
|
|
|
|
# Restore all backed-up files
|
|
|
|
ynh_restore
|
2017-06-17 17:28:57 +02:00
|
|
|
|
|
|
|
# Create and restore the database
|
|
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
|
|
|
|
|
|
|
# Reload
|
2020-07-01 17:14:15 +02:00
|
|
|
systemctl reload nginx
|
|
|
|
systemctl restart supervisor
|
|
|
|
supervisorctl restart budget
|
2020-07-01 18:46:50 +02:00
|
|
|
|
|
|
|
# Wait that gunicorn is ready to consider the install finished, that is to
|
|
|
|
# avoid HTTP 502 right after installation
|
|
|
|
for i in `seq 1 120`
|
|
|
|
do
|
|
|
|
test -S /tmp/budget.gunicorn.sock && break
|
|
|
|
sleep 1
|
|
|
|
done
|