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:
parent
82e8288105
commit
b714710429
3 changed files with 28 additions and 15 deletions
|
@ -12,7 +12,6 @@ AJAX interface to allow users to manage their own calendars and shared ones.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
* Update the `backup` and `restore` scripts
|
|
||||||
* Test the upgrade from the 1.x to the 2.x
|
* Test the upgrade from the 1.x to the 2.x
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
# Set app specific variables
|
# Set app specific variables
|
||||||
app="agendav"
|
app="agendav"
|
||||||
dbname=$app
|
dbname=$app
|
||||||
dbuser=$app
|
dbuser=$app
|
||||||
|
|
||||||
# Source app helpers
|
# Source YunoHost helpers
|
||||||
. /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
@ -19,6 +21,7 @@ ynh_backup "$DESTDIR" "sources"
|
||||||
|
|
||||||
# Copy the conf files
|
# Copy the conf files
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
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
|
# Dump the database
|
||||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
# Set app specific variables
|
# Set app specific variables
|
||||||
app="agendav"
|
app="agendav"
|
||||||
dbname=$app
|
dbname=$app
|
||||||
dbuser=$app
|
dbuser=$app
|
||||||
|
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
. /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve old app settings
|
# Retrieve old app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
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 \
|
[[ -f $nginx_conf ]] && ynh_die \
|
||||||
"The NGINX configuration already exists at '${nginx_conf}'.
|
"The NGINX configuration already exists at '${nginx_conf}'.
|
||||||
You should safely delete it before restoring this app."
|
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
|
# Check whether Baïkal or Radicale is installed
|
||||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||||
caldav_app="baikal"
|
caldav_app="baikal"
|
||||||
caldav_principal_path="/cal.php/%u/"
|
caldav_baseurl="/cal.php/"
|
||||||
caldav_calendar_path="/cal.php/calendars/%s/"
|
|
||||||
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
|
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
|
||||||
caldav_app="radicale"
|
caldav_app="radicale"
|
||||||
caldav_principal_path="/%u/"
|
caldav_baseurl="/"
|
||||||
caldav_calendar_path="/%s/"
|
|
||||||
else
|
else
|
||||||
ynh_die "You must install Baïkal or Radicale before"
|
ynh_die "You must install Baïkal or Radicale before"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore the app files and set permissions
|
# Restore the app files and set permissions
|
||||||
sudo cp -a ./sources "$DESTDIR"
|
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 config
|
||||||
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
||||||
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
||||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||||
caldav_conf="${DESTDIR}/web/application/config/caldav.php"
|
conf_path="${DESTDIR}/web/config/settings.php"
|
||||||
sudo sed -i "s@^\(\$config\['caldav_principal_url'\] = \).*\
|
sudo sed -i "s@^\(\$app\['caldav.baseurl'\] = \).*\
|
||||||
@\1'${caldav_url}${caldav_principal_path}';@g" "$caldav_conf"
|
@\1'${caldav_url}${caldav_baseurl}';@g" "$conf_path"
|
||||||
sudo sed -i "s@^\(\$config\['caldav_calendar_url'\] = \).*\
|
sudo sed -i "s@^\(\$app\['caldav.baseurl.public'\] = \).*\
|
||||||
@\1'${caldav_url}${caldav_calendar_path}';@g" "$caldav_conf"
|
@\1'${caldav_domain}';@g" "$conf_path"
|
||||||
|
|
||||||
# Create log directory
|
# Create log directory
|
||||||
sudo install -m 750 -o www-data -d "/var/log/${app}"
|
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
|
# Restore configuration files
|
||||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
sudo cp -a ./nginx.conf "$nginx_conf"
|
||||||
|
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service nginx reload || true
|
sudo service php5-fpm restart
|
||||||
|
sudo service nginx reload
|
||||||
|
|
Loading…
Add table
Reference in a new issue