2014-11-23 20:22:15 +01:00
|
|
|
#!/bin/bash
|
2015-10-23 16:24:30 +02:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
set -eu
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
app="kanboard"
|
2016-02-07 00:56:33 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Set app specific variables
|
|
|
|
dbname=$app
|
|
|
|
dbuser=$app
|
2016-02-07 00:56:33 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-02-07 00:56:33 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# 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)
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# TODO: Check domain/path availability with app helper
|
|
|
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
|
|
|
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Check destination directory
|
|
|
|
DESTDIR="/var/www/$app"
|
|
|
|
[[ -d $DESTDIR ]] && ynh_die \
|
|
|
|
"The destination directory '$DESTDIR' already exists.\
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
|
|
|
|
# Check configuration files
|
|
|
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
|
|
[[ -f $nginx_conf ]] && ynh_die \
|
|
|
|
"The NGINX configuration already exists at '${nginx_conf}'.
|
|
|
|
You should safely delete it before restoring this app."
|
|
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
|
|
[[ -f $phpfpm_conf ]] && ynh_die \
|
|
|
|
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
|
|
|
|
You should safely delete it before restoring this app."
|
2015-10-26 14:49:22 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Restore the app files
|
|
|
|
sudo cp -a ./www "$DESTDIR"
|
2014-12-22 18:57:15 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Create and restore the database
|
|
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
|
|
|
|
|
|
|
# Restore permissions
|
|
|
|
sudo chown -R root:root "$DESTDIR"
|
|
|
|
sudo chown -R www-data:www-data "$DESTDIR"/data
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Restore configuration files
|
|
|
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
|
|
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
2016-02-07 00:56:33 +01:00
|
|
|
|
2016-07-23 14:54:26 +02:00
|
|
|
# Reload services
|
|
|
|
sudo service php5-fpm restart || true
|
|
|
|
sudo service nginx reload || true
|