1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00

[enh] Update the backup and restore scripts regarding changes

This commit is contained in:
Jérôme Lebleu 2016-07-15 15:16:35 +02:00
parent 82e8288105
commit b714710429
3 changed files with 28 additions and 15 deletions

View file

@ -12,7 +12,6 @@ AJAX interface to allow users to manage their own calendars and shared ones.
## TODO
* Update the `backup` and `restore` scripts
* Test the upgrade from the 1.x to the 2.x
## Links

View file

@ -1,12 +1,14 @@
#!/bin/bash
set -eu
# Set app specific variables
app="agendav"
dbname=$app
dbuser=$app
# Source app helpers
. /usr/share/yunohost/helpers
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
@ -19,6 +21,7 @@ ynh_backup "$DESTDIR" "sources"
# Copy the conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
# Dump the database
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql

View file

@ -1,12 +1,14 @@
#!/bin/bash
set -eu
# Set app specific variables
app="agendav"
dbname=$app
dbuser=$app
# Source app helpers
. /usr/share/yunohost/helpers
source /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
@ -28,33 +30,40 @@ 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."
# Check whether Baïkal or Radicale is installed
if sudo yunohost app list --installed -f baikal | grep -q id ; then
caldav_app="baikal"
caldav_principal_path="/cal.php/%u/"
caldav_calendar_path="/cal.php/calendars/%s/"
caldav_baseurl="/cal.php/"
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
caldav_app="radicale"
caldav_principal_path="/%u/"
caldav_calendar_path="/%s/"
caldav_baseurl="/"
else
ynh_die "You must install Baïkal or Radicale before"
fi
# Restore the app files and set permissions
sudo cp -a ./sources "$DESTDIR"
sudo chown -R www-data: "$DESTDIR"
sudo chown -hR root: "$DESTDIR"
sudo chown -hR www-data: "${DESTDIR}/web"
sudo chmod -R 750 "${DESTDIR}/web/var"
# Clean caches
sudo rm -rf "${DESTDIR}/web/var/cache/"{profiler,twig}/*
# CalDAV config
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_conf="${DESTDIR}/web/application/config/caldav.php"
sudo sed -i "s@^\(\$config\['caldav_principal_url'\] = \).*\
@\1'${caldav_url}${caldav_principal_path}';@g" "$caldav_conf"
sudo sed -i "s@^\(\$config\['caldav_calendar_url'\] = \).*\
@\1'${caldav_url}${caldav_calendar_path}';@g" "$caldav_conf"
conf_path="${DESTDIR}/web/config/settings.php"
sudo sed -i "s@^\(\$app\['caldav.baseurl'\] = \).*\
@\1'${caldav_url}${caldav_baseurl}';@g" "$conf_path"
sudo sed -i "s@^\(\$app\['caldav.baseurl.public'\] = \).*\
@\1'${caldav_domain}';@g" "$conf_path"
# Create log directory
sudo install -m 750 -o www-data -d "/var/log/${app}"
@ -65,6 +74,8 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
# Restore configuration files
sudo cp -a ./nginx.conf "$nginx_conf"
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
# Reload services
sudo service nginx reload || true
sudo service php5-fpm restart
sudo service nginx reload