2017-04-21 02:19:25 -06:00
|
|
|
#!/usr/bin/env bash
|
2019-01-07 01:04:17 -05:00
|
|
|
set -eo pipefail
|
|
|
|
|
[[ $DOKKU_TRACE ]] && set -x
|
2017-04-21 02:19:25 -06:00
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
|
|
|
|
|
|
2020-02-10 02:40:59 -05:00
|
|
|
trigger-nginx-vhosts-proxy-build-config() {
|
2017-04-21 02:19:25 -06:00
|
|
|
declare desc="build nginx config to proxy app containers from command line"
|
2020-02-10 02:40:59 -05:00
|
|
|
declare trigger="proxy-build-config"
|
2017-04-21 02:19:25 -06:00
|
|
|
declare APP="$1"
|
2022-11-27 19:50:57 -05:00
|
|
|
local HAS_NETWORK_CONFIG
|
2017-04-21 02:19:25 -06:00
|
|
|
|
2022-11-27 19:50:57 -05:00
|
|
|
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")"
|
|
|
|
|
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
2017-04-21 02:19:25 -06:00
|
|
|
plugn trigger network-build-config "$APP"
|
|
|
|
|
nginx_build_config "$APP"
|
2022-11-27 19:50:57 -05:00
|
|
|
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" ]]; then
|
|
|
|
|
mv "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
|
|
|
|
fi
|
|
|
|
|
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing" ]]; then
|
|
|
|
|
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
|
|
|
|
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
nginx_clear_config "$APP"
|
2017-04-21 02:19:25 -06:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-10 02:40:59 -05:00
|
|
|
trigger-nginx-vhosts-proxy-build-config "$@"
|