From d5df6a4190ee10c3d4ada37edf1f6fab1c1bbaad Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 28 Aug 2015 14:14:28 +0100 Subject: [PATCH 1/2] Use `$PLUGIN_PATH` instead of `$(dirname $0)/..` As briefly discussed in #1425, source the `common/functions` file via an absolute path, rather than determining the relative path by using `dirname`. 3rd-party plugins should follow suit and use the new `$PLUGIN_PATH` convention too. --- plugins/00_dokku-standard/commands | 2 +- plugins/20_events/commands | 2 +- plugins/20_events/hook | 2 +- plugins/20_events/install | 2 +- plugins/apps/commands | 2 +- plugins/build-env/pre-build | 2 +- plugins/checks/check-deploy | 2 +- plugins/config/commands | 2 +- plugins/config/docker-args-deploy | 2 +- plugins/docker-options/commands | 2 +- plugins/domains/commands | 2 +- plugins/git/commands | 2 +- plugins/git/receive-app | 2 +- plugins/nginx-vhosts/commands | 2 +- plugins/nginx-vhosts/post-deploy | 2 +- plugins/nginx-vhosts/post-domains-update | 2 +- plugins/ps/commands | 2 +- plugins/ps/functions | 4 ++-- plugins/ps/pre-deploy | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index eb939472d..7c71a143d 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" case "$1" in build) diff --git a/plugins/20_events/commands b/plugins/20_events/commands index 66b72704f..c3b817735 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" PLUGIN_DIR="$(dirname $0)" diff --git a/plugins/20_events/hook b/plugins/20_events/hook index 0f21da9fb..5357e931b 100755 --- a/plugins/20_events/hook +++ b/plugins/20_events/hook @@ -1,5 +1,5 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" [[ ! "$DOKKU_EVENTS" ]] || dokku_log_pluginhook_call "$(basename $0)" "$@" diff --git a/plugins/20_events/install b/plugins/20_events/install index 62435390f..8951bd4d1 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" DOKKU_RSYSLOG_FILTER=/etc/rsyslog.d/99-dokku.conf DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku diff --git a/plugins/apps/commands b/plugins/apps/commands index d1d157ce9..4e303e26d 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" case "$1" in apps) diff --git a/plugins/build-env/pre-build b/plugins/build-env/pre-build index 033973c40..e49148448 100755 --- a/plugins/build-env/pre-build +++ b/plugins/build-env/pre-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV="" diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index 91b2493a1..1b30e9876 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -35,7 +35,7 @@ # set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1"; DOKKU_APP_CONTAINER_ID="$2"; DOKKU_APP_CONTAINER_TYPE="$3"; DOKKU_APP_LISTEN_PORT="$4"; DOKKU_APP_LISTEN_IP="$5" if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then diff --git a/plugins/config/commands b/plugins/config/commands index 11ec22ef7..35ffe39bf 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" config_create () { [ -f $ENV_FILE ] || { diff --git a/plugins/config/docker-args-deploy b/plugins/config/docker-args-deploy index 8d1f1ef24..2b475265b 100755 --- a/plugins/config/docker-args-deploy +++ b/plugins/config/docker-args-deploy @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" STDIN=$(cat); APP="$1"; IMAGE="dokku/$APP" DOCKERFILE_ENV_FILE="$DOKKU_ROOT/$APP/DOCKERFILE_ENV_FILE" diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index 7a54ff1fc..3834660a9 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" PHASES=(build deploy run) diff --git a/plugins/domains/commands b/plugins/domains/commands index dba5335ea..72ef45c97 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" RE_IPV4="([0-9]{1,3}[\.]){3}[0-9]{1,3}" diff --git a/plugins/git/commands b/plugins/git/commands index ce1ec5581..4848db0f3 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" git_build_app_repo() { verify_app_name "$1" diff --git a/plugins/git/receive-app b/plugins/git/receive-app index 328fbeb1d..7fe95cc1a 100755 --- a/plugins/git/receive-app +++ b/plugins/git/receive-app @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1"; REV="$2" diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 419f17934..c0d8ebb04 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" validate_nginx () { set +e diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/post-deploy index 145bdffa3..f2987d070 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/post-deploy @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1" if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then diff --git a/plugins/nginx-vhosts/post-domains-update b/plugins/nginx-vhosts/post-domains-update index 30d8006f4..945057998 100755 --- a/plugins/nginx-vhosts/post-domains-update +++ b/plugins/nginx-vhosts/post-domains-update @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1" diff --git a/plugins/ps/commands b/plugins/ps/commands index f6e7e6480..bdebeaa3b 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" source "$(dirname $0)/functions" case "$1" in diff --git a/plugins/ps/functions b/plugins/ps/functions index 0cb73beac..6517d8259 100755 --- a/plugins/ps/functions +++ b/plugins/ps/functions @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" release_and_deploy() { - source "$(dirname $0)/../common/functions" + source "$PLUGIN_PATH/common/functions" local APP="$1"; local IMAGE="dokku/$APP" if verify_image "$IMAGE"; then diff --git a/plugins/ps/pre-deploy b/plugins/ps/pre-deploy index bc4f77c94..80488ed13 100755 --- a/plugins/ps/pre-deploy +++ b/plugins/ps/pre-deploy @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" source "$(dirname $0)/functions" APP="$1" From 9637884861bb83dfab88c411a23f230f0731640d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 28 Aug 2015 14:27:48 +0100 Subject: [PATCH 2/2] Update docs with `$PLUGIN_PATH` instead of `$(dirname $0)/..` --- docs/development/plugin-creation.md | 2 +- docs/development/pluginhooks.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 001fe34fb..55098a826 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -15,7 +15,7 @@ The below plugin is a dummy `dokku hello` plugin. If your plugin exposes command ```shell #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" case "$1" in hello) diff --git a/docs/development/pluginhooks.md b/docs/development/pluginhooks.md index b725be799..c61df9176 100644 --- a/docs/development/pluginhooks.md +++ b/docs/development/pluginhooks.md @@ -253,7 +253,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" dokku_log_info1" Installing GraphicsMagick..." @@ -279,7 +279,7 @@ docker commit $ID $IMAGE > /dev/null set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" dokku_log_info1" Installing $CONTAINER_PACKAGE..." @@ -360,7 +360,7 @@ fi set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_PATH/common/functions" APP="$1" IMAGE="dokku/$APP"