#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= #source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= # Exit on command errors and treat access to unset variables as an error 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) #================================================= # 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 " conf="/etc/nginx/conf.d/$domain.d/$app.conf" test ! -f $conf \ || ynh_die "There is already a nginx conf file at this path: $conf " #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE BACKUP FILES #================================================= ynh_restore #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files chown -R root:www-data "$final_path" chmod -R 640 "$final_path" find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= systemctl reload nginx