From 467264d31f929c13134ecd95eed08cc0ef99eded Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 17 Sep 2015 02:00:23 -0700 Subject: [PATCH] Drop another ~1k lines from DOKKU_TRACE output --- plugins/20_events/commands | 3 +-- plugins/backup/commands | 3 +-- plugins/docker-options/commands | 15 ++++++----- plugins/domains/commands | 21 +--------------- plugins/domains/functions | 36 +++++++++++++++++++++++++++ plugins/nginx-vhosts/bind-external-ip | 1 - 6 files changed, 46 insertions(+), 33 deletions(-) diff --git a/plugins/20_events/commands b/plugins/20_events/commands index 11f3a2b15..d3d0a16f4 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -2,8 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -PLUGIN_DIR="$(dirname $0)" - case "$1" in events) if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then @@ -27,6 +25,7 @@ case "$1" in ;; events:list) + PLUGIN_DIR="$(dirname $0)" if [[ "$DOKKU_EVENTS" ]]; then logged="$(find $PLUGIN_DIR -type l -printf '%f ' | sort)" dokku_col_log_info2_quiet "Events currently logged" diff --git a/plugins/backup/commands b/plugins/backup/commands index 2fa160979..9cd99a5ca 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -1,10 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -CURRENT_BACKUP_VERSION=1 - case "$1" in backup:export) + CURRENT_BACKUP_VERSION=1 OUTPUT_FILE="$2" BACKUP_DIR="$DOKKU_ROOT" diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index b7f63c55d..4148605d6 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -2,10 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -PHASES=(build deploy run) - -FILE_PREFIX="DOCKER_OPTIONS_" - get_app() { [[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$1" @@ -25,17 +21,19 @@ get_phases() { verify_phase() { local phase - for phase in "${PHASES[@]}"; do + local phases=(build deploy run) + for phase in "${phases[@]}"; do if [[ "$phase" = "$1" ]]; then return 0 fi done - dokku_log_fail "Phase(s) must be one of [${PHASES[@]}]" + dokku_log_fail "Phase(s) must be one of [${phases[@]}]" } get_phase_file_path() { local phase=$1 - phase_file_path="${DOKKU_ROOT}/${APP}/${FILE_PREFIX}${phase^^}" + local prefix="DOCKER_OPTIONS_" + phase_file_path="${DOKKU_ROOT}/${APP}/${prefix}${phase^^}" } create_phase_file_if_required() { @@ -53,7 +51,8 @@ display_phase_options() { } display_all_phases_options() { - for phase in "${PHASES[@]}"; do + local phases=(build deploy run) + for phase in "${phases[@]}"; do get_phase_file_path $phase if [[ -s $phase_file_path ]]; then display_phase_options $phase $phase_file_path diff --git a/plugins/domains/commands b/plugins/domains/commands index b7dea8836..f134e151c 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -4,26 +4,6 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" -RE_IPV4="([0-9]{1,3}[\.]){3}[0-9]{1,3}" - -RE_IPV6="([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|" # TEST: 1:2:3:4:5:6:7:8 -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,7}:|" # TEST: 1:: 1:2:3:4:5:6:7:: -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" # TEST: 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8 -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|" # TEST: 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8 -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|" # TEST: 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8 -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|" # TEST: 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8 -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|" # TEST: 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8 -RE_IPV6="${RE_IPV6}[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|" # TEST: 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8 -RE_IPV6="${RE_IPV6}:((:[0-9a-fA-F]{1,4}){1,7}|:)|" # TEST: ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 :: -RE_IPV6="${RE_IPV6}fe08:(:[0-9a-fA-F]{1,4}){2,2}%[0-9a-zA-Z]{1,}|" # TEST: fe08::7:8%eth0 fe08::7:8%1 (link-local IPv6 addresses with zone index) -RE_IPV6="${RE_IPV6}::(ffff(:0{1,4}){0,1}:){0,1}${RE_IPV4}|" # TEST: ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses) -RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}:${RE_IPV4}" # TEST: 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 - -# Ensure the ip address continues to the end of the line -# Fixes using a wildcard dns service such as xip.io which allows for *..xip.io -RE_IPV4="${RE_IPV4}\$" -RE_IPV6="${RE_IPV6}\$" - case "$1" in domains) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" @@ -43,6 +23,7 @@ case "$1" in [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" + RE_IPV4="$(get_ipv4_regex)"; RE_IPV6="$(get_ipv6_regex)" if [[ ! -f $VHOST_PATH ]]; then if [[ -f "$DOKKU_ROOT/VHOST" ]]; then diff --git a/plugins/domains/functions b/plugins/domains/functions index 2a69c42a0..0fbf9b774 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -6,3 +6,39 @@ get_app_domains() { local APP=$1; verify_app_name $APP cat "$DOKKU_ROOT/$APP/VHOST" } + +_ipv4_regex() { + echo "([0-9]{1,3}[\.]){3}[0-9]{1,3}" +} + +_ipv6_regex() { + local RE_IPV4="$(_ipv4_regex)" + local RE_IPV6="([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|" # TEST: 1:2:3:4:5:6:7:8 + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,7}:|" # TEST: 1:: 1:2:3:4:5:6:7:: + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" # TEST: 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8 + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|" # TEST: 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8 + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|" # TEST: 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8 + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|" # TEST: 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8 + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|" # TEST: 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8 + RE_IPV6="${RE_IPV6}[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|" # TEST: 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8 + RE_IPV6="${RE_IPV6}:((:[0-9a-fA-F]{1,4}){1,7}|:)|" # TEST: ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 :: + RE_IPV6="${RE_IPV6}fe08:(:[0-9a-fA-F]{1,4}){2,2}%[0-9a-zA-Z]{1,}|" # TEST: fe08::7:8%eth0 fe08::7:8%1 (link-local IPv6 addresses with zone index) + RE_IPV6="${RE_IPV6}::(ffff(:0{1,4}){0,1}:){0,1}${RE_IPV4}|" # TEST: ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses) + RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}:${RE_IPV4}" # TEST: 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 + echo "$RE_IPV6" +} + + +get_ipv4_regex() { + local RE_IPV4="$(_ipv4_regex)" + # Ensure the ip address continues to the end of the line + # Fixes using a wildcard dns service such as xip.io which allows for *..xip.io + echo "${RE_IPV4}\$" +} + +get_ipv6_regex() { + local RE_IPV6="$(_ipv4_regex)" + # Ensure the ip address continues to the end of the line + # Fixes using a wildcard dns service such as xip.io which allows for *..xip.io + echo "${RE_IPV6}\$" +} diff --git a/plugins/nginx-vhosts/bind-external-ip b/plugins/nginx-vhosts/bind-external-ip index b5f5c01d5..822989cfd 100755 --- a/plugins/nginx-vhosts/bind-external-ip +++ b/plugins/nginx-vhosts/bind-external-ip @@ -20,7 +20,6 @@ RE_IPV6="${RE_IPV6}fe08:(:[0-9a-fA-F]{1,4}){2,2}%[0-9a-zA-Z]{1,}|" # TEST: f RE_IPV6="${RE_IPV6}::(ffff(:0{1,4}){0,1}:){0,1}${RE_IPV4}|" # TEST: ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses) RE_IPV6="${RE_IPV6}([0-9a-fA-F]{1,4}:){1,4}:${RE_IPV4}" # TEST: 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 - # Ensure the ip address continues to the end of the line # Fixes using a wildcard dns service such as xip.io which allows for *..xip.io RE_IPV4="${RE_IPV4}\$"