Merge pull request #3103 from dokku/consolidate-vhost-references

Move all vhost related functions to the domains plugin
This commit is contained in:
Jose Diaz-Gonzalez
2018-03-08 09:48:38 -05:00
committed by GitHub
4 changed files with 125 additions and 123 deletions

View File

@@ -853,80 +853,6 @@ get_ipv6_regex() {
echo "${RE_IPV6}\$"
}
get_global_vhosts() {
declare desc="return global vhosts"
local GLOBAL_VHOST_FILE="$DOKKU_ROOT/VHOST"
[[ -f "$GLOBAL_VHOST_FILE" ]] && local GLOBAL_VHOSTS=$(< "$GLOBAL_VHOST_FILE")
echo "$GLOBAL_VHOSTS"
}
is_global_vhost_enabled() {
declare desc="returns true if we have a valid global vhost set; otherwise returns false"
local GLOBAL_VHOSTS=$(get_global_vhosts)
local GLOBAL_VHOSTS_ENABLED=false
local RE_IPV4="$(get_ipv4_regex)"
local RE_IPV6="$(get_ipv6_regex)"
while read -r GLOBAL_VHOST; do
if (is_valid_hostname "$GLOBAL_VHOST"); then
local GLOBAL_VHOSTS_ENABLED=true
break
fi
done <<< "$GLOBAL_VHOSTS"
echo $GLOBAL_VHOSTS_ENABLED
}
is_app_vhost_enabled() {
declare desc="returns true or false if vhost support is enabled for a given application"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
local APP=$1; verify_app_name "$APP"
local NO_VHOST=$(config_get "$APP" NO_VHOST)
local APP_VHOST_ENABLED=true
if [[ "$NO_VHOST" == "1" ]]; then
local APP_VHOST_ENABLED=false
fi
echo $APP_VHOST_ENABLED
}
disable_app_vhost() {
declare desc="disable vhost support for given application"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
local APP=$1; verify_app_name "$APP"
local APP_VHOST_FILE="$DOKKU_ROOT/$APP/VHOST"
local APP_URLS_FILE="$DOKKU_ROOT/$APP/URLS"
plugn trigger pre-disable-vhost "$APP"
if [[ -f "$APP_VHOST_FILE" ]]; then
dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST"
rm "$APP_VHOST_FILE"
fi
if [[ -f "$APP_URLS_FILE" ]]; then
dokku_log_info1 "VHOST support disabled, deleting $APP/URLS"
rm "$APP_URLS_FILE"
fi
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP NO_VHOST=1
}
enable_app_vhost() {
declare desc="enable vhost support for given application"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
local APP=$1; verify_app_name "$APP"
plugn trigger pre-enable-vhost "$APP"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS "$APP" NO_VHOST=0
}
get_dockerfile_exposed_ports() {
declare desc="return all exposed ports from passed file path"
local DOCKERFILE_PORTS=$(egrep "^EXPOSE " "$1" | awk '{ print $2 }' | xargs) || true
@@ -1105,16 +1031,6 @@ strip_inline_comments() {
echo "$stripped_line"
}
is_valid_hostname() {
declare desc="return 0 if argument is a valid hostname; else return 1"
local hostname_string="${1,,}"; local hostname_regex='^([a-z0-9\*-]+\.)*[a-z0-9\*-]+$'
if [[ $hostname_string =~ $hostname_regex ]]; then
return 0
else
return 1
fi
}
is_val_in_list() {
declare desc="return true if value ($1) is in list ($2) separated by delimiter ($3); delimiter defaults to comma"
local value="$1" list="$2" delimiter="${3:-,}"