1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/radicale_ynh.git synced 2024-09-03 20:16:14 +02:00
radicale_ynh/scripts/restore

126 lines
3.9 KiB
Text
Raw Normal View History

2016-04-07 00:00:41 +02:00
#!/bin/bash
2017-03-19 18:36:20 +01:00
#=================================================
# GENERIC STARTING
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-03-20 00:17:59 +01:00
if [ ! -e _common.sh ]; then
2017-03-19 18:36:20 +01:00
# Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
2017-03-20 00:17:59 +01:00
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
2017-03-19 18:36:20 +01:00
fi
2017-03-20 00:17:59 +01:00
source _common.sh
2016-12-14 16:13:20 +01:00
source /usr/share/yunohost/helpers
2017-03-19 18:36:20 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
2016-12-14 16:13:20 +01:00
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
infcloud=$(ynh_app_setting_get $app infcloud)
2017-03-19 18:36:20 +01:00
path_url=$(ynh_app_setting_get $app path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
test ! -d "/opt/yunohost/$app" \
|| ynh_die "There is already a directory: /opt/yunohost/$app "
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE OF THE NGINX CONFIGURATION
#=================================================
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2017-06-13 22:28:52 +02:00
# INSTALL DEPENDENCIES
2017-03-19 18:36:20 +01:00
#=================================================
2016-04-07 00:00:41 +02:00
2017-06-13 22:28:52 +02:00
ynh_install_app_dependencies python-pip python-virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2017-06-13 22:28:52 +02:00
# RESTORE OF THE MAIN DIR OF THE APP
2017-03-19 18:36:20 +01:00
#=================================================
2016-04-07 00:00:41 +02:00
2017-06-13 22:28:52 +02:00
ynh_restore_file "$final_path"
sudo mkdir -p /opt/yunohost
ynh_restore_file "/opt/yunohost/$app"
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
2016-08-05 17:00:50 +02:00
2017-03-19 18:36:20 +01:00
ynh_system_user_create $app # Recreate the dedicated user, if not exist
#=================================================
# RESTORE OF THE PHP-FPM CONFIGURATION
#=================================================
if [ $infcloud -eq 1 ]
then
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
2017-03-19 18:36:20 +01:00
sudo systemctl reload php5-fpm
2016-08-05 17:00:50 +02:00
fi
2017-03-19 18:36:20 +01:00
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE USER RIGHTS
#=================================================
2016-08-05 17:00:50 +02:00
sudo chown radicale: -R /opt/yunohost/$app
2016-12-14 16:13:20 +01:00
sudo chown -R radicale: $final_path
sudo mkdir -p /var/log/$app
sudo touch /var/log/$app/$app.log
sudo chown radicale -R /var/log/$app
2017-03-19 18:36:20 +01:00
#=================================================
# RESTORE THE UWSGI CONFIG
#=================================================
2016-12-14 16:13:20 +01:00
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/uwsgi/apps-available/radicale.ini"
2016-08-05 17:00:50 +02:00
sudo ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
2017-03-19 18:36:20 +01:00
#=================================================
# RESTORE THE RADICALE CONFIGURATION
#=================================================
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/$app"
2017-03-19 18:36:20 +01:00
#=================================================
# BACKUP OF THE LOGROTATE CONFIGURATION
#=================================================
2016-04-07 00:00:41 +02:00
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/logrotate.d/$app"
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX AND UWSGI
#=================================================
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
sudo systemctl restart uwsgi
2017-06-13 22:28:52 +02:00
sudo journalctl -xn
2017-03-19 18:36:20 +01:00
sudo systemctl reload nginx