#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # Load common variables for all scripts. source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= ynh_clean_setup () { # Clean installation remaining that are not handle by the remove script. 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 settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " #================================================= # ACTIVATE MAINTENANCE MODE #================================================= ynh_script_progression --message="Activating maintenance mode..." --weight=2 ynh_maintenance_mode_ON #================================================= # STANDARD RESTORE STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring $app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files chown -R $app: $final_path #================================================= # SPECIFIC RESTORE #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=60 ynh_install_app_dependencies $pkg_depencencies #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app --log $final_path/log/production.log #================================================= # RESTORE SYSTEMD #================================================= ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet #================================================= # RESTORE THE CRON FILE #================================================= ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # SETUP LOG FILE #================================================= # Making log a symbolic link to /var/log mkdir -p /var/log/$app/ touch /var/log/$app/production.log chown $app -R /var/log/$app #================================================= # RESTORE LOGROTATE CONFIGURATION #================================================= ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload #================================================= # START AND CHECK LUTIM BOOTING #================================================= ynh_script_progression --message="Restarting $app..." --weight=3 # Wait for lutim to be fully started ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" #================================================= # DEACTIVE MAINTENANCE MODE #================================================= ynh_script_progression --message="Disabling maintenance mode..." --weight=7 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" echo "You can find a config file at $final_path/lutim.conf 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/lutim_ynh__URL_TAG3__." > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last