reverseproxy_ynh/scripts/restore
2023-01-08 14:46:10 +01:00

51 lines
1.6 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
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
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path)
assets_path=$(ynh_app_setting_get --app=$app --key=assets_path)
#=================================================
# REVERSEPROXY_YNH
#=================================================
# Revalidate destination path
rp_validate_proxy_path "$proxy_path"
# Check configuration files
NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
[[ -f $NGINX_CONF ]] && ynh_die "The NGINX configuration already exists at '${NGINX_CONF}'. You should safely delete it before restoring this app."
# Restore configuration files
ynh_restore_file "$NGINX_CONF"
# Reload nginx
rp_reload_web
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last