2016-06-20 23:43:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-05-26 10:27:01 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-06-20 23:43:51 +02:00
|
|
|
|
2018-05-26 10:27:01 +02:00
|
|
|
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
|
|
|
|
#=================================================
|
2016-06-20 23:43:51 +02:00
|
|
|
|
|
|
|
# Retrieve arguments
|
2019-05-15 18:42:44 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2016-06-20 23:43:51 +02:00
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2019-05-09 23:08:09 +02:00
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
2016-06-20 23:43:51 +02:00
|
|
|
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\+&@#/%=~_|]'
|
2019-04-29 20:49:40 +02:00
|
|
|
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
|
2016-06-20 23:43:51 +02:00
|
|
|
|
|
|
|
# Check configuration files
|
|
|
|
NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
2019-04-29 20:49:40 +02:00
|
|
|
[[ -f $NGINX_CONF ]] && ynh_die "The NGINX configuration already exists at '${NGINX_CONF}'. You should safely delete it before restoring this app."
|
2016-06-20 23:43:51 +02:00
|
|
|
|
|
|
|
# Restore configuration files
|
2019-05-15 18:42:44 +02:00
|
|
|
ynh_restore_file "$NGINX_CONF"
|
2016-06-20 23:43:51 +02:00
|
|
|
|
2018-05-26 10:27:01 +02:00
|
|
|
#=================================================
|
2019-05-15 18:42:44 +02:00
|
|
|
# CONFIGURE SSOWAT
|
2018-05-26 10:27:01 +02:00
|
|
|
#=================================================
|
|
|
|
|
2016-06-20 23:43:51 +02:00
|
|
|
# Make app public if necessary
|
2019-05-15 18:35:57 +02:00
|
|
|
if [ "$redirect_type" != "private_proxy" ]
|
2016-06-20 23:43:51 +02:00
|
|
|
then
|
2018-05-26 10:27:01 +02:00
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2016-06-20 23:43:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
2019-05-15 18:42:44 +02:00
|
|
|
systemctl reload nginx
|