mirror of
https://github.com/YunoHost-Apps/kanboard_ynh.git
synced 2024-09-03 19:36:17 +02:00
60 lines
1.7 KiB
Bash
60 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
# Source local helpers
|
|
source ./_common.sh
|
|
|
|
# Source app helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Abort script if errors
|
|
ynh_abort_if_errors
|
|
|
|
app="kanboard"
|
|
|
|
# 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)
|
|
|
|
# TODO: Check domain/path availability with app helper
|
|
yunohost app checkurl "${domain}${path}" -a "$app" \
|
|
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
|
|
|
# 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."
|
|
|
|
# Restore the app files
|
|
cp -a ./www "$DESTDIR"
|
|
|
|
# Create and restore the database
|
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
|
|
|
# Restore permissions
|
|
chown -R root:root "$DESTDIR"
|
|
chown -R www-data ${DESTDIR}/{data,plugins}
|
|
|
|
# Restore configuration files
|
|
cp -a ./conf/nginx.conf "$nginx_conf"
|
|
cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
|
|
|
# Reload services
|
|
service php5-fpm restart || true
|
|
service nginx reload || true
|