2016-02-09 00:48:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-02-14 10:58:25 +01:00
|
|
|
set -eu
|
2016-02-09 00:48:21 +01:00
|
|
|
|
2017-03-12 19:46:53 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
db_user=$app
|
|
|
|
db_name=$app
|
2016-02-09 00:48:21 +01:00
|
|
|
|
|
|
|
|
2017-02-14 09:40:18 +01:00
|
|
|
# Source app helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
|
|
|
|
2016-02-09 00:48:21 +01:00
|
|
|
# retrieve useful param
|
2017-03-12 19:46:53 +01:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
|
|
|
dbpass=$(ynh_app_setting_get $app mysqlpwd)
|
2016-02-09 00:48:21 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
2017-03-12 19:46:53 +01:00
|
|
|
sudo yunohost app checkurl $domain$path -a $app || ynh_die "The path ${domain}${path} is not available for app installation."
|
2016-02-09 00:48:21 +01:00
|
|
|
|
|
|
|
# Restore sources & data
|
2017-03-12 19:46:53 +01:00
|
|
|
final_path=/var/www/$app
|
2016-02-09 00:48:21 +01:00
|
|
|
sudo mkdir $final_path
|
2017-03-12 19:46:53 +01:00
|
|
|
ynh_backup "www" "$final_path"
|
2016-02-09 00:48:21 +01:00
|
|
|
|
|
|
|
# Restore permissions
|
|
|
|
sudo chown -R root:root $final_path
|
|
|
|
sudo chown -R www-data: $final_path/data/
|
|
|
|
sudo chown -R www-data: $final_path/extensions/
|
|
|
|
|
|
|
|
# Restore conf files
|
2017-03-13 13:39:53 +01:00
|
|
|
ynh_backup nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2017-03-12 20:56:26 +01:00
|
|
|
ynh_backup $app.cron /etc/cron.d/$app
|
2016-02-09 00:48:21 +01:00
|
|
|
|
|
|
|
# Restore mysql dump
|
2017-03-05 20:57:54 +01:00
|
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
2017-03-12 19:46:53 +01:00
|
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "$app.dmp"
|
2017-03-05 20:57:54 +01:00
|
|
|
|
2016-02-09 00:48:21 +01:00
|
|
|
# Reload Nginx, and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|