#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME 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) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) admin=$(ynh_app_setting_get --app=$app --key=admin) infcloud=$(ynh_app_setting_get --app=$app --key=infcloud) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " test ! -d "/opt/yunohost/$app" \ || ynh_die --message="There is already a directory: /opt/yunohost/$app " #================================================= # ACTIVATE MAINTENANCE MODE #================================================= ynh_script_progression --message="Activate maintenance mode" ynh_maintenance_mode_ON #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= 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" mkdir -p /opt/yunohost ynh_restore_file --origin_path="/opt/yunohost/$app" chown -R radicale: "/opt/yunohost/$app" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= if [ $infcloud -eq 1 ] then ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" fi #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/etc/$app/" #================================================= # RESTORE SYSTEMD #================================================= ynh_script_progression --message="Restoring the systemd configuration..." # if ynh_compare_current_package_version --comparison le --version 1.1.6~ynh6 version=$(ynh_app_upstream_version) if [ $version == 1.1.6 ] then ynh_restore_file --origin_path="/etc/uwsgi/apps-available/radicale.ini" ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/ else ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service fi #================================================= # 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" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --log="/var/log/$app" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="restart" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= 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 ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE #================================================= ynh_script_progression --message="Disable maintenance mode" ynh_maintenance_mode_OFF #================================================= # SEND A README FOR THE ADMIN #================================================= # 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" if [ $infcloud -eq 1 ] then infcloud_config=" InfCloud has its own config file, at $final_path/infcloud/config.js " else infcloud_config="" fi echo "Use the file /etc/radicale/config to change the main configuration of radicale. The file /etc/radicale/logging to change the level of logging. And the file /etc/radicale/rights to edit the way the calendars will be shared. $infcloud_config 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__. 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 ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="restore" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app"