mirror of
https://github.com/YunoHost-Apps/reverseproxy_ynh.git
synced 2024-09-03 20:16:23 +02:00
52 lines
1.7 KiB
Bash
52 lines
1.7 KiB
Bash
#!/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
|
|
#=================================================
|
|
|
|
# Retrieve arguments
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
|
redirect_type=$(ynh_app_setting_get "$app" redirect_type)
|
|
redirect_path=$(ynh_app_setting_get "$app" redirect_path)
|
|
|
|
# Validate redirect path
|
|
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
|
|
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
|
|
|
|
# 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"
|
|
|
|
#=================================================
|
|
# CONFIGURE SSOWAT
|
|
#=================================================
|
|
|
|
# Make app public if necessary
|
|
if [ "$redirect_type" != "private_proxy" ]
|
|
then
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
fi
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
systemctl reload nginx
|