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

165 lines
5.2 KiB
Text
Raw Normal View History

2016-04-07 00:00:41 +02:00
#!/bin/bash
2017-03-19 18:36:20 +01:00
#=================================================
2017-09-05 00:34:00 +02:00
# GENERIC START
2017-03-19 18:36:20 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2018-07-13 17:36:34 +02:00
source ../settings/scripts/_common.sh
2016-12-14 16:13:20 +01:00
source /usr/share/yunohost/helpers
2017-09-05 00:34:00 +02:00
# Load common variables for all scripts.
source ../settings/scripts/_variables
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2016-12-14 16:13:20 +01:00
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)
2017-12-17 01:04:15 +01:00
admin=$(ynh_app_setting_get $app admin)
2017-03-19 18:36:20 +01:00
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2017-12-16 23:29:00 +01:00
ynh_webpath_available $domain $path_url \
2017-03-19 18:36:20 +01:00
|| 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 "
2018-07-13 17:36:34 +02:00
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_ON
2017-03-19 18:36:20 +01:00
#=================================================
# STANDARD RESTORE STEPS
#=================================================
2019-01-18 21:12:58 +01:00
# RESTORE THE NGINX CONFIGURATION
2017-03-19 18:36:20 +01:00
#=================================================
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
#=================================================
2019-01-18 21:12:58 +01:00
# REINSTALL DEPENDENCIES
2017-03-19 18:36:20 +01:00
#=================================================
2016-04-07 00:00:41 +02:00
2017-09-05 00:34:00 +02:00
ynh_install_app_dependencies $app_depencencies
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2019-01-18 21:12:58 +01:00
# RESTORE THE APP MAIN DIR
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"
2017-09-05 00:34:00 +02:00
mkdir -p /opt/yunohost
2017-06-13 22:28:52 +02:00
ynh_restore_file "/opt/yunohost/$app"
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2019-01-18 21:12:58 +01:00
# RECREATE THE DEDICATED USER
2017-03-19 18:36:20 +01:00
#=================================================
2016-08-05 17:00:50 +02:00
2019-01-18 21:12:58 +01:00
# Create the dedicated user (if not existing)
ynh_system_user_create $app
2017-03-19 18:36:20 +01:00
#=================================================
2019-01-18 21:12:58 +01:00
# RESTORE THE PHP-FPM CONFIGURATION
2017-03-19 18:36:20 +01:00
#=================================================
if [ $infcloud -eq 1 ]
then
2017-06-13 22:28:52 +02:00
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
2019-01-18 21:12:58 +01:00
ynh_systemd_action --action=reload --service_name=php5-fpm
2016-08-05 17:00:50 +02:00
fi
2017-03-19 18:36:20 +01:00
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE USER RIGHTS
#=================================================
2017-09-05 00:34:00 +02:00
chown radicale: -R /opt/yunohost/$app
2016-08-05 17:00:50 +02:00
2017-09-05 00:34:00 +02:00
chown -R radicale: $final_path
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
2016-12-14 16:13:20 +01:00
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"
2017-09-05 00:34:00 +02:00
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
2016-08-05 17:00:50 +02:00
2019-01-18 21:12:58 +01:00
# Advertise service in admin panel
2017-12-05 19:41:20 +01:00
yunohost service add uwsgi --log "/var/log/uwsgi/app/radicale.log"
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
2019-01-18 21:12:58 +01:00
ynh_systemd_action --action=restart --service_name=uwsgi
ynh_systemd_action --action=reload --service_name=nginx
2018-07-13 17:36:34 +02:00
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_OFF
2017-12-16 23:29:00 +01:00
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
2019-01-21 13:22:56 +01:00
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
2017-12-16 23:29:00 +01:00
if [ $infcloud -eq 1 ]
then
infcloud_config="
InfCloud has its own config file, at $final_path/infcloud/config.js
"
else
infcloud_config=""
fi
message="Use the file /etc/radicale/config to change the main configuration of radicale.
The file /etc/radicale/logging to change the level of logging.
2019-01-18 21:12:58 +01:00
And the file /etc/radicale/rights to edit the way the calendars will be shared.
2017-12-16 23:29:00 +01:00
$infcloud_config
2019-01-21 13:22:56 +01:00
You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
2019-01-18 21:12:58 +01:00
If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/radicale_ynh"
2017-12-16 23:29:00 +01:00
2019-01-21 13:22:56 +01:00
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="restore"