2016-06-14 17:36:26 -07:00
|
|
|
#!/usr/bin/env bash
|
2019-01-07 01:04:17 -05:00
|
|
|
set -eo pipefail
|
|
|
|
|
[[ $DOKKU_TRACE ]] && set -x
|
2016-06-14 17:36:26 -07:00
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
|
|
|
|
|
2020-02-10 02:40:59 -05:00
|
|
|
trigger-nginx-vhosts-pre-enable-vhost() {
|
2016-06-14 17:36:26 -07:00
|
|
|
declare desc="unset port prior to vhosts being enabled"
|
2020-02-10 02:40:59 -05:00
|
|
|
declare trigger="pre-enable-vhost"
|
|
|
|
|
declare APP="$1"
|
|
|
|
|
|
2025-11-20 00:21:40 -05:00
|
|
|
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
|
|
|
|
return
|
2016-06-14 17:36:26 -07:00
|
|
|
fi
|
2025-11-20 00:21:40 -05:00
|
|
|
|
|
|
|
|
# only clear ports if they are port 80 or 443
|
|
|
|
|
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
|
|
|
|
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
|
|
|
|
|
|
|
|
|
ports_to_clear=()
|
|
|
|
|
if [[ "$PROXY_PORT" == "80" ]]; then
|
|
|
|
|
ports_to_clear+=("DOKKU_PROXY_PORT")
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
|
|
|
|
ports_to_clear+=("DOKKU_PROXY_SSL_PORT")
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then
|
|
|
|
|
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# clear ports if there is a mapping starting with http:80 or https:443
|
|
|
|
|
local PORT_MAPS=$(plugn trigger ports-get "$APP")
|
|
|
|
|
for PORT_MAP in $PORT_MAPS; do
|
|
|
|
|
if [[ "$PORT_MAP" == "http:80:"* ]] || [[ "$PORT_MAP" == "https:443:"* ]]; then
|
|
|
|
|
plugn trigger ports-clear "$APP"
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
2016-06-14 17:36:26 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 02:40:59 -05:00
|
|
|
trigger-nginx-vhosts-pre-enable-vhost "$@"
|