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

202 lines
7.1 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
#=================================================
2022-03-18 22:47:33 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
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
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2022-03-18 22:47:33 +01:00
ynh_clean_setup () {
ynh_clean_check_starting
}
2017-09-05 00:34:00 +02:00
# 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
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Loading installation settings..."
2017-03-19 18:36:20 +01:00
app=$YNH_APP_INSTANCE_NAME
2022-03-18 22:47:33 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
2020-12-07 09:05:15 +01:00
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
2022-03-18 22:47:33 +01:00
admin=$(ynh_app_setting_get --app=$app --key=admin)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
2017-03-19 18:36:20 +01:00
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Validating restoration parameters..."
2017-03-19 18:36:20 +01:00
test ! -d $final_path \
2022-03-18 22:47:33 +01:00
|| ynh_die --message="There is already a directory: $final_path "
2017-03-19 18:36:20 +01:00
test ! -d "/opt/yunohost/$app" \
2022-03-18 22:47:33 +01:00
|| ynh_die --message="There is already a directory: /opt/yunohost/$app "
2017-03-19 18:36:20 +01:00
2018-07-13 17:36:34 +02:00
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Activate maintenance mode"
2018-07-13 17:36:34 +02:00
ynh_maintenance_mode_ON
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# STANDARD RESTORATION STEPS
2017-03-19 18:36:20 +01:00
#=================================================
2019-01-18 21:12:58 +01:00
# RESTORE THE NGINX CONFIGURATION
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Restoring the NGINX web server configuration..."
2017-03-19 18:36:20 +01:00
2022-03-18 22:47:33 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# RECREATE THE DEDICATED USER
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Recreating the dedicated system user..."
2016-04-07 00:00:41 +02:00
2022-03-18 22:47:33 +01:00
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
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
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2016-04-07 00:00:41 +02:00
2017-09-05 00:34:00 +02:00
mkdir -p /opt/yunohost
2022-03-18 22:47:33 +01:00
ynh_restore_file --origin_path="/opt/yunohost/$app"
2016-04-07 00:00:41 +02:00
2022-03-18 22:47:33 +01:00
chown -R radicale: "/opt/yunohost/$app"
2016-08-05 17:00:50 +02:00
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
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
2016-08-05 17:00:50 +02:00
fi
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# SPECIFIC RESTORATION
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# REINSTALL DEPENDENCIES
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Reinstalling dependencies..."
2017-03-19 18:36:20 +01:00
2022-03-18 22:47:33 +01:00
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
2016-08-05 17:00:50 +02:00
2022-03-18 22:47:33 +01:00
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app/"
2016-12-14 16:13:20 +01:00
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# RESTORE SYSTEMD
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Restoring the systemd configuration..."
2016-12-14 16:13:20 +01:00
2022-03-18 22:47:33 +01:00
ynh_restore_file --origin_path="/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
2022-03-18 22:47:33 +01:00
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2017-12-05 19:41:20 +01:00
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Integrating service in YunoHost..."
2017-03-19 18:36:20 +01:00
2022-03-18 22:47:33 +01:00
yunohost service add $app --log="/var/log/uwsgi/app/radicale.log"
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# START SYSTEMD SERVICE
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Starting a systemd service..."
2016-04-07 00:00:41 +02:00
2022-03-18 22:47:33 +01:00
ynh_systemd_action --service_name=uwsgi --action=restart
2016-04-07 00:00:41 +02:00
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# GENERIC FINALIZATION
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
# RELOAD NGINX AND PHP-FPM
2017-03-19 18:36:20 +01:00
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
if [ $infcloud -eq 1 ]
then
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
fi
2016-04-07 00:00:41 +02:00
2022-03-18 22:47:33 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2018-07-13 17:36:34 +02:00
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Disable maintenance mode"
2018-07-13 17:36:34 +02:00
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
2019-01-30 19:30:41 +01:00
echo "Use the file /etc/radicale/config to change the main configuration of radicale.
2017-12-16 23:29:00 +01:00
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-30 19:30:41 +01:00
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
2019-01-21 13:22:56 +01:00
2019-01-30 19:30:41 +01:00
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/radicale_ynh__URL_TAG3__." > mail_to_send
2017-12-16 23:29:00 +01:00
2019-01-30 19:30:41 +01:00
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="restore"
2019-01-30 19:16:04 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2022-03-18 22:47:33 +01:00
ynh_script_progression --message="Restoration completed for $app"