#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) # is_public is now a boolean field if [ "$is_public" = "Yes" ]; then is_public=1 fi #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_restore_file "$final_path" #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files chown -R root: $final_path #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app --log "/var/log/$app/APP.log" # Make app public if necessary [[ $is_public -eq 1 ]] \ && ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= systemctl reload nginx