From b6c4a750deb381b58761d0be04ea82f091788760 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Fri, 18 Sep 2015 15:32:33 +0200 Subject: [PATCH 1/9] Support removing config variables that contain `\n`. --- plugins/config/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/config/functions b/plugins/config/functions index 6dca410bb..eeb0db2f9 100644 --- a/plugins/config/functions +++ b/plugins/config/functions @@ -211,7 +211,7 @@ config_unset() { for var in $VARS; do dokku_log_info1 "Unsetting $var" - ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $var=/ d") + ENV_TEMP=$(echo "${ENV_TEMP}" | sed "/^export $var=/ d") config_write "$ENV_TEMP" done From 7a0161dd866a66fe7cdcbb1328447a966d20fb11 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Fri, 18 Sep 2015 15:34:46 +0200 Subject: [PATCH 2/9] Add a testcase. --- tests/unit/config.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/config.bats b/tests/unit/config.bats index 10e1239d9..d32131403 100644 --- a/tests/unit/config.bats +++ b/tests/unit/config.bats @@ -77,7 +77,7 @@ teardown() { } @test "(config) config:unset" { - run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" + run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" test_var3=\"with\\nnewline\" echo "output: "$output echo "status: "$status assert_success @@ -93,6 +93,10 @@ teardown() { echo "output: "$output echo "status: "$status assert_output "" + run dokku config:get $TEST_APP test_var3 + echo "output: "$output + echo "status: "$status + assert_output 'with\nnewline' } @test "(config) global config (herokuish)" { From 068810ad366dad9311600518600011e483d4c087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Tom=C3=A1s=20Albornoz?= Date: Fri, 18 Sep 2015 18:32:52 +0200 Subject: [PATCH 3/9] Herokush -> herokuish not that kind of kush --- docs/upgrading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrading.md b/docs/upgrading.md index f1b234eac..e2041e731 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -42,7 +42,7 @@ dokku ps:rebuildall If dokku was installed via a debian package, you can upgrade herokuish via the following command: ```shell -sudo apt-get install Herokush +sudo apt-get install herokuish ``` For unattended upgrades, you may run the following command: From b9ecb32d3f8984600e80286793dd538188946d5d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 16 Sep 2015 23:56:08 -0700 Subject: [PATCH 4/9] Reduce deploy trace output for multi-container applications This reduces deploy output by moving `config:get` calls out of the main loop. Since the values are the same for each iteration, it does not make sense to re-retrieve them each time. --- dokku | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dokku b/dokku index c3dd36337..8469e8b5f 100755 --- a/dokku +++ b/dokku @@ -80,6 +80,14 @@ case "$1" in DOKKU_RESTART_LIMIT=$(dokku config:get $APP DOKKU_RESTART_LIMIT || echo 10) DOKKU_RESTART_LIMIT=${DOKKU_RESTART_LIMIT:=10} + DOKKU_APP_SKIP_ALL_CHECKS=$(dokku config:get $APP DOKKU_SKIP_ALL_CHECKS || true) + DOKKU_APP_SKIP_DEFAULT_CHECKS=$(dokku config:get $APP DOKKU_SKIP_DEFAULT_CHECKS || true) + DOKKU_GLOBAL_SKIP_ALL_CHECKS=$(dokku config:get --global DOKKU_SKIP_ALL_CHECKS || true) + DOKKU_GLOBAL_SKIP_DEFAULT_CHECKS=$(dokku config:get --global DOKKU_SKIP_DEFAULT_CHECKS || true) + + DOKKU_SKIP_ALL_CHECKS=${DOKKU_APP_SKIP_ALL_CHECKS:="$DOKKU_GLOBAL_SKIP_ALL_CHECKS"} + DOKKU_SKIP_DEFAULT_CHECKS=${DOKKU_APP_SKIP_DEFAULT_CHECKS:="$DOKKU_GLOBAL_SKIP_DEFAULT_CHECKS"} + while read line || [[ -n "$line" ]]; do TRIM=${line%#*} PROC_TYPE=${TRIM%%=*} @@ -127,14 +135,6 @@ case "$1" in kill -9 $$ } - DOKKU_APP_SKIP_ALL_CHECKS=$(dokku config:get $APP DOKKU_SKIP_ALL_CHECKS || true) - DOKKU_APP_SKIP_DEFAULT_CHECKS=$(dokku config:get $APP DOKKU_SKIP_DEFAULT_CHECKS || true) - DOKKU_GLOBAL_SKIP_ALL_CHECKS=$(dokku config:get --global DOKKU_SKIP_ALL_CHECKS || true) - DOKKU_GLOBAL_SKIP_DEFAULT_CHECKS=$(dokku config:get --global DOKKU_SKIP_DEFAULT_CHECKS || true) - - DOKKU_SKIP_ALL_CHECKS=${DOKKU_APP_SKIP_ALL_CHECKS:="$DOKKU_GLOBAL_SKIP_ALL_CHECKS"} - DOKKU_SKIP_DEFAULT_CHECKS=${DOKKU_APP_SKIP_DEFAULT_CHECKS:="$DOKKU_GLOBAL_SKIP_DEFAULT_CHECKS"} - # run checks first, then post-deploy hooks, which switches Nginx traffic if [[ "$DOKKU_SKIP_ALL_CHECKS" = "true" ]]; then dokku_log_info1 "Skipping pre-flight checks" From 1e543afb7851e9efe8efd79964d16d0766219da4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 16 Sep 2015 23:57:23 -0700 Subject: [PATCH 5/9] Retrieve default docker args a single time --- dokku | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dokku b/dokku index 8469e8b5f..b15993024 100755 --- a/dokku +++ b/dokku @@ -88,6 +88,8 @@ case "$1" in DOKKU_SKIP_ALL_CHECKS=${DOKKU_APP_SKIP_ALL_CHECKS:="$DOKKU_GLOBAL_SKIP_ALL_CHECKS"} DOKKU_SKIP_DEFAULT_CHECKS=${DOKKU_APP_SKIP_DEFAULT_CHECKS:="$DOKKU_GLOBAL_SKIP_DEFAULT_CHECKS"} + DOKKU_DEFAULT_DOCKER_ARGS=$(: | plugn trigger docker-args-deploy $APP $IMAGE_TAG) + while read line || [[ -n "$line" ]]; do TRIM=${line%#*} PROC_TYPE=${TRIM%%=*} @@ -101,9 +103,9 @@ case "$1" in DOKKU_PORT_FILE="$DOKKU_ROOT/$APP/PORT.$PROC_TYPE.$CONTAINER_INDEX" # start the app - DOCKER_ARGS=" -e DYNO='$PROC_TYPE.$CONTAINER_INDEX' " + DOCKER_ARGS="$DOKKU_DEFAULT_DOCKER_ARGS" + DOCKER_ARGS+=" -e DYNO='$PROC_TYPE.$CONTAINER_INDEX' " DOCKER_ARGS+=" --restart=on-failure:$DOKKU_RESTART_LIMIT" - DOCKER_ARGS+=$(: | plugn trigger docker-args-deploy $APP $IMAGE_TAG) [[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true " BIND_EXTERNAL=$(plugn trigger bind-external-ip $APP) From 467264d31f929c13134ecd95eed08cc0ef99eded Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 17 Sep 2015 02:00:23 -0700 Subject: [PATCH 6/9] 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}\$" From 70511c340dfea9bff4c0b5172280705eccbc90e1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 17 Sep 2015 02:43:51 -0700 Subject: [PATCH 7/9] Check if command is implemented in a plugin before executing plugin code Because of how plugin commands are implemented, their output can be incredibly verbose. Rather than executing even the `set -eo pipefail` parts of a plugin, we immediately check if the command is implemented by a plugin. If it is not, then we continue on as normal. One side-effect of this change is that plugin commands need to be duplicated again: - once in the command array - once for the actual body of the command - once in the help output This is also quite hackish, and probably not the best way to decrease trace output. Note that we drop approximately 2k lines worth of logs with this change. --- plugins/00_dokku-standard/commands | 1 + plugins/20_events/commands | 1 + plugins/apps/commands | 1 + plugins/backup/commands | 1 + plugins/certs/commands | 1 + plugins/config/commands | 1 + plugins/docker-options/commands | 1 + plugins/domains/commands | 1 + plugins/enter/commands | 1 + plugins/nginx-vhosts/commands | 1 + plugins/plugin/commands | 1 + plugins/ps/commands | 1 + plugins/shell/commands | 1 + plugins/tags/commands | 1 + plugins/tar/commands | 1 + 15 files changed, 15 insertions(+) diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index af5e43770..1e3d39b3e 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " build release trace delete ls logs run url urls version help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" diff --git a/plugins/20_events/commands b/plugins/20_events/commands index d3d0a16f4..582b5c38f 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " events events:on events:off events:list help events:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" diff --git a/plugins/apps/commands b/plugins/apps/commands index 93052e0d0..a73e97975 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " apps apps:create apps:destroy help apps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" diff --git a/plugins/backup/commands b/plugins/backup/commands index 9cd99a5ca..90f28a4ad 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " backup:export backup:import help backup:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in diff --git a/plugins/certs/commands b/plugins/certs/commands index ba6e62bc0..1ecacd41c 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " certs:add certs:generate certs:info certs:remove certs:update help certs:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/certs/functions" diff --git a/plugins/config/commands b/plugins/config/commands index 191af9f52..f5b929449 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " config config:get config:set config:unset help config:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index 4148605d6..a1396c1cc 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " docker-options docker-options:add docker-options:remove help docker-options:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" diff --git a/plugins/domains/commands b/plugins/domains/commands index f134e151c..36f4ffa2c 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " domains domains:setup domains:add domains:clear domains:remove help domains:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" diff --git a/plugins/enter/commands b/plugins/enter/commands index b8e0bdbdc..b69217e98 100755 --- a/plugins/enter/commands +++ b/plugins/enter/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " enter help enter:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 3851cdceb..c3508c967 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " nginx:build-config nginx:access-logs nginx:error-logs help nginx:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/certs/functions" diff --git a/plugins/plugin/commands b/plugins/plugin/commands index 8df025c37..d4eb65327 100755 --- a/plugins/plugin/commands +++ b/plugins/plugin/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " plugin plugin:install plugin:install-dependencies plugin:update plugin:disable plugin:enable plugin:uninstall help plugin:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/plugin/functions" diff --git a/plugins/ps/commands b/plugins/ps/commands index d9614c623..3e0a7357a 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " ps ps:start ps:stop ps:rebuild ps:rebuildall ps:restart ps:restartall ps:scale help ps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" diff --git a/plugins/shell/commands b/plugins/shell/commands index f64e231aa..16fec26f4 100755 --- a/plugins/shell/commands +++ b/plugins/shell/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " shell help shell:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in diff --git a/plugins/tags/commands b/plugins/tags/commands index 58061e835..9990485a9 100755 --- a/plugins/tags/commands +++ b/plugins/tags/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " tags tags:create tags:deploy tags:destroy help tags:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/tags/functions" diff --git a/plugins/tar/commands b/plugins/tar/commands index 76da3766f..e57faeabd 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +[[ " tar-from tar:from tar-in tar:in tar-build tar-build-locked help tar:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" From d3c218f95e7d8daff301f7aa968eb8d0ad50bd2c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 17 Sep 2015 02:44:05 -0700 Subject: [PATCH 8/9] Add help commands to docker-options and tar plugins --- plugins/docker-options/commands | 2 +- plugins/tar/commands | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index a1396c1cc..2a9589978 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -139,7 +139,7 @@ case "$1" in ;; # Display usage help - help) + help | docker-options:help) cat<, Display apps docker options for all phases docker-options , Display apps docker options for phase (comma separated phase list) diff --git a/plugins/tar/commands b/plugins/tar/commands index e57faeabd..519ae4e15 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -58,7 +58,7 @@ case "$1" in fi ;; - help) + help | tar:help) cat && cat<, Reads an tarball containing the app from stdin tar:from , Loads an app tarball from url. From f914e6207b24ee9dc8cd68215e8487d5cb7a42d0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 18 Sep 2015 16:15:26 -0400 Subject: [PATCH 9/9] Consolidate ipv4/ipv6 regex declarations behing nginx-vhosts plugin --- plugins/domains/commands | 1 + plugins/domains/functions | 36 ------------------------- plugins/nginx-vhosts/bind-external-ip | 22 ++-------------- plugins/nginx-vhosts/functions | 38 +++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 56 deletions(-) create mode 100755 plugins/nginx-vhosts/functions diff --git a/plugins/domains/commands b/plugins/domains/commands index 36f4ffa2c..d71c10db7 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -4,6 +4,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" case "$1" in domains) diff --git a/plugins/domains/functions b/plugins/domains/functions index 0fbf9b774..2a69c42a0 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -6,39 +6,3 @@ 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 822989cfd..5c1456333 100755 --- a/plugins/nginx-vhosts/bind-external-ip +++ b/plugins/nginx-vhosts/bind-external-ip @@ -4,26 +4,8 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" APP="$1" NO_VHOST=$(config_get $APP NO_VHOST || true) - -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}\$" +RE_IPV4="$(get_ipv4_regex)" +RE_IPV6="$(get_ipv6_regex)" [[ -f "$DOKKU_ROOT/VHOST" ]] && GLOBAL_VHOST=$(< "$DOKKU_ROOT/VHOST") diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions new file mode 100755 index 000000000..a246cb229 --- /dev/null +++ b/plugins/nginx-vhosts/functions @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + +_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}\$" +}