Create default app domain for every global domain
This commit is contained in:
1 parent
164f48913f
commit
371949f4ec
3 files changed
+32
-29
No files matched your search
@@ -814,24 +814,24 @@ get_ipv6_regex() {
|
|||||||
echo "${RE_IPV6}\$"
|
echo "${RE_IPV6}\$"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_global_vhost() {
|
get_global_vhosts() {
|
||||||
declare desc="return global vhost"
|
declare desc="return global vhosts"
|
||||||
local GLOBAL_VHOST_FILE="$DOKKU_ROOT/VHOST"
|
local GLOBAL_VHOST_FILE="$DOKKU_ROOT/VHOST"
|
||||||
[[ -f "$GLOBAL_VHOST_FILE" ]] && local GLOBAL_VHOST=$(< "$GLOBAL_VHOST_FILE")
|
[[ -f "$GLOBAL_VHOST_FILE" ]] && local GLOBAL_VHOSTS=$(< "$GLOBAL_VHOST_FILE")
|
||||||
echo "$GLOBAL_VHOST"
|
echo "$GLOBAL_VHOSTS"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_global_vhost_enabled() {
|
is_global_vhost_enabled() {
|
||||||
declare desc="returns true if we have a valid global vhost set; otherwise returns false"
|
declare desc="returns true if we have a valid global vhost set; otherwise returns false"
|
||||||
local GLOBAL_VHOST=$(get_global_vhost)
|
local GLOBAL_VHOSTS=$(get_global_vhosts)
|
||||||
local GLOBAL_VHOST_ENABLED=true
|
local GLOBAL_VHOSTS_ENABLED=true
|
||||||
local RE_IPV4="$(get_ipv4_regex)"
|
local RE_IPV4="$(get_ipv4_regex)"
|
||||||
local RE_IPV6="$(get_ipv6_regex)"
|
local RE_IPV6="$(get_ipv6_regex)"
|
||||||
|
|
||||||
if [[ -z "$GLOBAL_VHOST" ]] || [[ "$GLOBAL_VHOST" =~ $RE_IPV4 ]] || [[ "$GLOBAL_VHOST" =~ $RE_IPV6 ]]; then
|
if [[ -z "$GLOBAL_VHOSTS" ]] || [[ "$GLOBAL_VHOSTS" =~ $RE_IPV4 ]] || [[ "$GLOBAL_VHOSTS" =~ $RE_IPV6 ]]; then
|
||||||
local GLOBAL_VHOST_ENABLED=false
|
local GLOBAL_VHOSTS_ENABLED=false
|
||||||
fi
|
fi
|
||||||
echo $GLOBAL_VHOST_ENABLED
|
echo $GLOBAL_VHOSTS_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
is_app_vhost_enabled() {
|
is_app_vhost_enabled() {
|
||||||
|
|||||||
+22
-19
@@ -20,27 +20,30 @@ get_app_domains() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_default_vhost() {
|
get_default_vhosts() {
|
||||||
declare desc="return default vhost"
|
declare desc="return default vhost"
|
||||||
verify_app_name "$1"
|
verify_app_name "$1"
|
||||||
local APP="$1"; local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
local APP="$1"; local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
||||||
|
|
||||||
|
|
||||||
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
|
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
|
||||||
local VHOST=$(get_global_vhost)
|
local VHOSTS=$(get_global_vhosts)
|
||||||
if ! ([[ "$VHOST" =~ $RE_IPV4 ]] || [[ "$VHOST" =~ $RE_IPV6 ]]); then
|
|
||||||
local SUBDOMAIN=${APP/%\.${VHOST}/}
|
while read -r VHOST; do
|
||||||
local hostname=$(: | plugn trigger nginx-hostname "$APP" "$SUBDOMAIN" "$VHOST")
|
if ! ([[ "$VHOST" =~ $RE_IPV4 ]] || [[ "$VHOST" =~ $RE_IPV6 ]]); then
|
||||||
if [[ ! -n $hostname ]]; then
|
local SUBDOMAIN=${APP/%\.${VHOST}/}
|
||||||
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
|
local hostname=$(: | plugn trigger nginx-hostname "$APP" "$SUBDOMAIN" "$VHOST")
|
||||||
local hostname="${APP/\//-}"
|
if [[ ! -n $hostname ]]; then
|
||||||
else
|
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
|
||||||
local hostname="${APP/\//-}.$VHOST"
|
local hostname="${APP/\//-}"
|
||||||
|
else
|
||||||
|
local hostname="${APP/\//-}.$VHOST"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "$hostname"
|
||||||
fi
|
fi
|
||||||
local DEFAULT_VHOST="$hostname"
|
done <<< "$VHOSTS"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
echo "$DEFAULT_VHOST"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
domains_setup() {
|
domains_setup() {
|
||||||
@@ -48,12 +51,12 @@ domains_setup() {
|
|||||||
verify_app_name "$1"
|
verify_app_name "$1"
|
||||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||||
local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
||||||
local DEFAULT_VHOST="$(get_default_vhost "$APP")"
|
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
||||||
|
|
||||||
if [[ ! -f $APP_VHOST_PATH ]]; then
|
if [[ ! -f $APP_VHOST_PATH ]]; then
|
||||||
if [[ -n "$DEFAULT_VHOST" ]]; then
|
if [[ -n "$DEFAULT_VHOSTS" ]]; then
|
||||||
dokku_log_info1 "Creating new $APP_VHOST_PATH..."
|
dokku_log_info1 "Creating new $APP_VHOST_PATH..."
|
||||||
echo "$DEFAULT_VHOST" > "$APP_VHOST_PATH"
|
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
|
||||||
else
|
else
|
||||||
dokku_log_info2 "no global VHOST set. disabling vhost support"
|
dokku_log_info2 "no global VHOST set. disabling vhost support"
|
||||||
disable_app_vhost "$APP" --no-restart
|
disable_app_vhost "$APP" --no-restart
|
||||||
@@ -118,11 +121,11 @@ domains_enable() {
|
|||||||
declare desc="enable domains/VHOST support"
|
declare desc="enable domains/VHOST support"
|
||||||
verify_app_name "$1"
|
verify_app_name "$1"
|
||||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||||
local DEFAULT_VHOST="$(get_default_vhost "$APP")"
|
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
||||||
|
|
||||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
|
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
|
||||||
if [[ -n "$DEFAULT_VHOST" ]]; then
|
if [[ -n "$DEFAULT_VHOSTS" ]]; then
|
||||||
echo "$DEFAULT_VHOST" > "$APP_VHOST_PATH"
|
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
|
||||||
fi
|
fi
|
||||||
[[ "$2" == "--no-restart" ]] && local ENABLE_APP_VHOST_ARGS=$2
|
[[ "$2" == "--no-restart" ]] && local ENABLE_APP_VHOST_ARGS=$2
|
||||||
enable_app_vhost "$APP" "$ENABLE_APP_VHOST_ARGS"
|
enable_app_vhost "$APP" "$ENABLE_APP_VHOST_ARGS"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ domains_main_cmd() {
|
|||||||
|
|
||||||
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
|
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
|
||||||
dokku_log_info2_quiet "Global Domain Name"
|
dokku_log_info2_quiet "Global Domain Name"
|
||||||
get_global_vhost
|
get_global_vhosts
|
||||||
fi
|
fi
|
||||||
if [[ -n "$APP" ]]; then
|
if [[ -n "$APP" ]]; then
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|||||||
Reference in new issue
Block a user