From e78cc9bd364725edb1e990bed4de5fec0d577df5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 24 Apr 2018 15:05:55 -0400 Subject: [PATCH 01/33] Use --if-exists with import To resolve https://github.com/dokku/dokku-postgres/issues/142 --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index da9ddcf..7540549 100755 --- a/functions +++ b/functions @@ -114,7 +114,7 @@ service_import() { if [[ -t 0 ]]; then dokku_log_fail "No data provided on stdin." fi - docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO -d "$DATABASE_NAME" -U postgres -w + docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO --if-exists -d "$DATABASE_NAME" -U postgres -w } service_start() { From d143bb48b037b5b1bd22cbe951d65de93c061ed6 Mon Sep 17 00:00:00 2001 From: Dan Poirier Date: Mon, 30 Apr 2018 14:29:30 -0400 Subject: [PATCH 02/33] Update test to expect --if-exists on import --- tests/service_import.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service_import.bats b/tests/service_import.bats index a9dfb1c..e6a83e5 100755 --- a/tests/service_import.bats +++ b/tests/service_import.bats @@ -32,6 +32,6 @@ teardown() { export ECHO_DOCKER_COMMAND="true" run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.dump" password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO -d l -U postgres -w" + assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO --if-exists -d l -U postgres -w" } From 59d285f2f17373b310409892022e4352214c0808 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 00:14:08 -0400 Subject: [PATCH 03/33] feat: add ability to upgrade service image and image-version --- README.md | 1 + common-functions | 23 +++++++++++++++++++++++ functions | 5 ++--- subcommands/upgrade | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100755 subcommands/upgrade diff --git a/README.md b/README.md index 83a4cdd..df20416 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ postgres:start Start a previously stopped postgres service postgres:stop Stop a running postgres service postgres:unexpose Unexpose a previously exposed postgres service postgres:unlink Unlink the postgres service from the app +postgres:upgrade Upgrade service to the specified version ``` ## usage diff --git a/common-functions b/common-functions index 5ff4442..bbbff15 100755 --- a/common-functions +++ b/common-functions @@ -273,6 +273,18 @@ service_backup_unset_encryption() { rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT" } +service_container_rm() { + declare desc="Stops a service and removes the running container" + declare SERVICE="$1" + local SERVICE_NAME="$(get_service_name "$SERVICE")" + + service_stop "$SERVICE" + dokku_log_info2_quiet "Removing container" + if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then + dokku_log_fail "Unable to stop container for service $SERVICE" + fi +} + service_enter() { declare desc="enters running app container of specified proc type" declare SERVICE="$1" && shift 1 @@ -300,6 +312,17 @@ service_exposed_ports() { done } +service_image_exists() { + declare desc="Checks if the current image exists" + local IMAGE="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + + if [[ "$(docker images -q "$IMAGE" 2> /dev/null)" == "" ]]; then + return 0 + fi + + return 1 +} + service_info() { declare desc="Retrieves information about a given service" declare SERVICE="$1" INFO_FLAG="$2" diff --git a/functions b/functions index da9ddcf..7a9ba73 100755 --- a/functions +++ b/functions @@ -29,7 +29,7 @@ service_create() { service_parse_args "${@:2}" - if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then + if ! service_image_exists "$SERVICE"; then if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2 dokku_log_warn " docker pull ${IMAGE}" 1>&2 @@ -130,14 +130,13 @@ service_start() { dokku_log_info2_quiet "Starting container" local PREVIOUS_ID=$(docker ps -f status=exited | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true - local IMAGE_EXISTS=$(docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " && true) local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" if [[ -n $PREVIOUS_ID ]]; then docker start "$PREVIOUS_ID" > /dev/null service_port_unpause "$SERVICE" dokku_log_info2 "Container started" - elif $IMAGE_EXISTS && [[ -n "$PASSWORD" ]]; then + elif service_image_exists "$SERVICE" && [[ -n "$PASSWORD" ]]; then service_create_container "$SERVICE" else dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE" diff --git a/subcommands/upgrade b/subcommands/upgrade new file mode 100755 index 0000000..a518733 --- /dev/null +++ b/subcommands/upgrade @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_BASE_PATH/common/functions" +source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" + +service-upgrade-cmd() { + #E you can upgrade an existing service to a new image or image-version + #E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop + #A service, service to run command against + #F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with + #F -i|--image IMAGE, the image name to start the service with + #F -i|--image-version IMAGE_VERSION, the image version to start the service with + declare desc="upgrade service to the specified versions" + local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare SERVICE="$1" CLONE_FLAGS_LIST="${@:2}" + is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" + + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + verify_service_name "$SERVICE" + + local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" + local ID="$(cat "$SERVICE_ROOT/ID")" + is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running" + + PLUGIN_IMAGE=$(service_version "$SERVICE" | grep -o "^.*:" | sed -r "s/://g") + PLUGIN_IMAGE_VERSION=$(service_version "$SERVICE" | grep -o ":.*$" | sed -r "s/://g") + + service_parse_args "${@:2}" + + if ! service_image_exists "$SERVICE"; then + dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist" + fi + + dokku_log_info2 "Stopping $SERVICE" + service_container_rm "$NEW_SERVICE" + dokku_log_info2 "Upgrading $SERVICE @ $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + service_start "$NEW_SERVICE" "${@:2}" + dokku_log_info2 "Done" +} + +service-upgrade-cmd "$@" From 9ee6c3c5cfd470bf4fdb48ab120f2874e261efaf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:32:59 -0400 Subject: [PATCH 04/33] chore: remove unnecessary call --- subcommands/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index a518733..3e390b1 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -14,7 +14,6 @@ service-upgrade-cmd() { declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" CLONE_FLAGS_LIST="${@:2}" - is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" verify_service_name "$SERVICE" From c05c47187a2e28ab1fc8ab061ce4dea3349b3a80 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:39:11 -0400 Subject: [PATCH 05/33] fix: do not force-set plugin image and version to existing image and version --- subcommands/upgrade | 3 --- 1 file changed, 3 deletions(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index 3e390b1..e012e10 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -22,9 +22,6 @@ service-upgrade-cmd() { local ID="$(cat "$SERVICE_ROOT/ID")" is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running" - PLUGIN_IMAGE=$(service_version "$SERVICE" | grep -o "^.*:" | sed -r "s/://g") - PLUGIN_IMAGE_VERSION=$(service_version "$SERVICE" | grep -o ":.*$" | sed -r "s/://g") - service_parse_args "${@:2}" if ! service_image_exists "$SERVICE"; then From 9010e1551f569d8b6fd05daca2d694b96dd85838 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:42:43 -0400 Subject: [PATCH 06/33] fix: correct check for existing image --- common-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common-functions b/common-functions index bbbff15..7bd6d52 100755 --- a/common-functions +++ b/common-functions @@ -317,10 +317,10 @@ service_image_exists() { local IMAGE="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" if [[ "$(docker images -q "$IMAGE" 2> /dev/null)" == "" ]]; then - return 0 + return 1 fi - return 1 + return 0 } service_info() { From ea3cd5ef30144661fd93f52278cde6050339f977 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:49:30 -0400 Subject: [PATCH 07/33] fix: pass correct variable for upgrade command --- subcommands/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index e012e10..4333a93 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -29,9 +29,9 @@ service-upgrade-cmd() { fi dokku_log_info2 "Stopping $SERVICE" - service_container_rm "$NEW_SERVICE" + service_container_rm "$SERVICE" dokku_log_info2 "Upgrading $SERVICE @ $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" - service_start "$NEW_SERVICE" "${@:2}" + service_start "$SERVICE" "${@:2}" dokku_log_info2 "Done" } From 902545bdb4b7da2369ff2cc6a8ef6a2192972192 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:54:34 -0400 Subject: [PATCH 08/33] chore: correct verbiage around upgrades --- common-functions | 4 ++-- subcommands/upgrade | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common-functions b/common-functions index 7bd6d52..c5bd0bb 100755 --- a/common-functions +++ b/common-functions @@ -279,9 +279,9 @@ service_container_rm() { local SERVICE_NAME="$(get_service_name "$SERVICE")" service_stop "$SERVICE" - dokku_log_info2_quiet "Removing container" + dokku_log_verbose_quiet "Removing container" if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then - dokku_log_fail "Unable to stop container for service $SERVICE" + dokku_log_fail "Unable to remove container for service $SERVICE" fi } diff --git a/subcommands/upgrade b/subcommands/upgrade index 4333a93..8f3cd62 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -28,9 +28,9 @@ service-upgrade-cmd() { dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist" fi + dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" dokku_log_info2 "Stopping $SERVICE" service_container_rm "$SERVICE" - dokku_log_info2 "Upgrading $SERVICE @ $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" service_start "$SERVICE" "${@:2}" dokku_log_info2 "Done" } From 21cc07bd48a376e5b81f0deec4883030b9c9e961 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 02:59:24 -0400 Subject: [PATCH 09/33] Release 1.4.0 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index e3b17d6..55c5a7e 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.3.1" +version = "1.4.0" [plugin.config] From 0a8d599965abe19cdc3167bb51bf9774d10048d7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 03:00:22 -0400 Subject: [PATCH 10/33] fix: correct name for upgrade flags in help output --- subcommands/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index 8f3cd62..72fcf5d 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -13,7 +13,7 @@ service-upgrade-cmd() { #F -i|--image-version IMAGE_VERSION, the image version to start the service with declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 - declare SERVICE="$1" CLONE_FLAGS_LIST="${@:2}" + declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" verify_service_name "$SERVICE" From 7382058ecb99f527342c4f90bc9d9c8d1d641553 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 03:01:17 -0400 Subject: [PATCH 11/33] Release 1.4.1 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 55c5a7e..f95307b 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.0" +version = "1.4.1" [plugin.config] From 76e0d5fd87747018eeef9c7a1434f0ff3200d81e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 03:02:56 -0400 Subject: [PATCH 12/33] fix: correct short-flag for image-version and custom-env --- subcommands/clone | 4 ++-- subcommands/create | 4 ++-- subcommands/upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/subcommands/clone b/subcommands/clone index 6c8beb3..ab0e073 100755 --- a/subcommands/clone +++ b/subcommands/clone @@ -9,9 +9,9 @@ service-clone-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:clone lolipop lolipop-2 #A service, service to run command against #A new-service, name of new service - #F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with + #F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with #F -i|--image IMAGE, the image name to start the service with - #F -i|--image-version IMAGE_VERSION, the image version to start the service with + #F -I|--image-version IMAGE_VERSION, the image version to start the service with #F -p|--password PASSWORD, override the user-level service password #F -r|--root-password PASSWORD, override the root-level service password declare desc="create container then copy data from into " diff --git a/subcommands/create b/subcommands/create index f8456e4..e5135b3 100755 --- a/subcommands/create +++ b/subcommands/create @@ -17,9 +17,9 @@ service-create-cmd() { #E export ${PLUGIN_DEFAULT_ALIAS}_CUSTOM_ENV="USER=alpha;HOST=beta" #E dokku $PLUGIN_COMMAND_PREFIX:create lolipop #A service, service to run command against - #F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with + #F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with #F -i|--image IMAGE, the image name to start the service with - #F -i|--image-version IMAGE_VERSION, the image version to start the service with + #F -I|--image-version IMAGE_VERSION, the image version to start the service with #F -p|--password PASSWORD, override the user-level service password #F -r|--root-password PASSWORD, override the root-level service password declare desc="create a $PLUGIN_SERVICE service" diff --git a/subcommands/upgrade b/subcommands/upgrade index 72fcf5d..b4718c8 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -8,9 +8,9 @@ service-upgrade-cmd() { #E you can upgrade an existing service to a new image or image-version #E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop #A service, service to run command against - #F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with + #F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with #F -i|--image IMAGE, the image name to start the service with - #F -i|--image-version IMAGE_VERSION, the image version to start the service with + #F -I|--image-version IMAGE_VERSION, the image version to start the service with declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}" From dda9ed6d55fc36ca006d5d74452550decd741088 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 03:03:40 -0400 Subject: [PATCH 13/33] Release 1.4.2 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index f95307b..ec45359 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.1" +version = "1.4.2" [plugin.config] From 969a9cdcb04a76a54aba9bd39148a3c799daa0ed Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 09:39:51 -0400 Subject: [PATCH 14/33] Release 1.4.3 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index ec45359..9d20806 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.2" +version = "1.4.3" [plugin.config] From 66e8279dca0c65a9c4bd680941abd347d004fde9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 09:40:45 -0400 Subject: [PATCH 15/33] Release 1.4.4 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 9d20806..274cecc 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.3" +version = "1.4.4" [plugin.config] From d470ade7a72f3165585f5541a91041c69f72a811 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 22:03:44 -0400 Subject: [PATCH 16/33] fix: handle case where container being removed does not exist --- common-functions | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common-functions b/common-functions index c5bd0bb..02470a5 100755 --- a/common-functions +++ b/common-functions @@ -279,9 +279,12 @@ service_container_rm() { local SERVICE_NAME="$(get_service_name "$SERVICE")" service_stop "$SERVICE" + local ID=$(docker inspect "$SERVICE_NAME" -f '{{ .ID }}' 2> /dev/null || true) + [[ -z "$ID" ]] && return 0 + dokku_log_verbose_quiet "Removing container" if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then - dokku_log_fail "Unable to remove container for service $SERVICE" + dokku_log_fail "Unable to remove container for service $SERVICE" fi } From 8823baf480553879678733794e3c5116256d407d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:14:45 -0400 Subject: [PATCH 17/33] feat: add support for restarting containers to ensure links continue to work properly when the application has resolved dns of the link --- common-functions | 30 ++++++++++++++++-------------- subcommands/upgrade | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/common-functions b/common-functions index 02470a5..c5d3d5d 100755 --- a/common-functions +++ b/common-functions @@ -474,24 +474,24 @@ service_parse_args() { for arg in "$@"; do shift case "$arg" in - "--config-options") set -- "$@" "-c" ;; - "--custom-env") set -- "$@" "-C" ;; - "--image") set -- "$@" "-i" ;; - "--image-version") set -- "$@" "-I" ;; - "--password") set -- "$@" "-p" ;; - "--root-password") set -- "$@" "-r" ;; - - "--alias") set -- "$@" "-a" ;; - "--database") set -- "$@" "-d" ;; - "--memory") set -- "$@" "-m" ;; - "--querystring") set -- "$@" "-q" ;; - "--user") set -- "$@" "-u" ;; - *) set -- "$@" "$arg" + "--alias") set -- "$@" "-a" ;; + "--config-options") set -- "$@" "-c" ;; + "--custom-env") set -- "$@" "-C" ;; + "--database") set -- "$@" "-d" ;; + "--image-version") set -- "$@" "-I" ;; + "--image") set -- "$@" "-i" ;; + "--memory") set -- "$@" "-m" ;; + "--password") set -- "$@" "-p" ;; + "--querystring") set -- "$@" "-q" ;; + "--restart-apps") set -- "$@" "-R" ;; + "--root-password") set -- "$@" "-r" ;; + "--user") set -- "$@" "-u" ;; + *) set -- "$@" "$arg" esac done OPTIND=1 - while getopts "a:c:C:d:i:I:m:p:q:r:u:" opt; do + while getopts "a:c:C:d:i:I:m:p:q:R:r:u:" opt; do case "$opt" in a) SERVICE_ALIAS="${OPTARG^^}"; export SERVICE_ALIAS="${SERVICE_ALIAS%_URL}" @@ -512,6 +512,8 @@ service_parse_args() { ;; q) export SERVICE_QUERYSTRING=${OPTARG#"?"} ;; + R) export SERVICE_RESTART_APPS=$OPTARG + ;; r) export SERVICE_ROOT_PASSWORD=$OPTARG ;; u) export SERVICE_USER=$OPTARG diff --git a/subcommands/upgrade b/subcommands/upgrade index b4718c8..ef9ae2d 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -3,6 +3,7 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_BASE_PATH/common/functions" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" +source "$PLUGIN_AVAILABLE_PATH/ps/functions" service-upgrade-cmd() { #E you can upgrade an existing service to a new image or image-version @@ -11,6 +12,7 @@ service-upgrade-cmd() { #F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with #F -i|--image IMAGE, the image name to start the service with #F -I|--image-version IMAGE_VERSION, the image version to start the service with + #F -R|--restart-apps "true", whether to force an app restart declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}" @@ -29,9 +31,24 @@ service-upgrade-cmd() { fi dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then + dokku_log_info2 "Stopping all linked services" + for app in $(service_linked_apps "$SERVICE"); do + ps_stop "$app" + done + fi + dokku_log_info2 "Stopping $SERVICE" service_container_rm "$SERVICE" service_start "$SERVICE" "${@:2}" + + if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then + dokku_log_info2 "Starting all linked services" + for app in $(service_linked_apps "$SERVICE"); do + ps_start "$app" + done + fi + dokku_log_info2 "Done" } From 30de0727abe32f90d17adc2fcc7bc308a7985045 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:18:41 -0400 Subject: [PATCH 18/33] Release 1.4.5 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 274cecc..5d49410 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.4" +version = "1.4.5" [plugin.config] From d1121442932791e507f44328696783bc174c0fa7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:23:10 -0400 Subject: [PATCH 19/33] fix: correct issue where temp help output files were being placed in incorrect directory --- help-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help-functions b/help-functions index f87209c..6752433 100755 --- a/help-functions +++ b/help-functions @@ -76,7 +76,7 @@ fn-help-contents() { fn-help-contents-subcommand() { declare SUBCOMMAND="$1" FULL_OUTPUT="$2" local TMPDIR=$(mktemp -d) - local UNCLEAN_FILE="${TMPDIR}cmd-unclean" CLEAN_FILE="${TMPDIR}cmd-clean" + local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean" local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT From c05aa74a3eb95e975a16772b6bcd0fb24b24fe55 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:27:36 -0400 Subject: [PATCH 20/33] Release 1.4.6 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 5d49410..ae7fb20 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.5" +version = "1.4.6" [plugin.config] From 73a8ccc08500750abe0d2d3064e5077ec3095f49 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:31:52 -0400 Subject: [PATCH 21/33] fix: ensure flags are properly represented in help output --- subcommands/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index ef9ae2d..ba27943 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -15,7 +15,7 @@ service-upgrade-cmd() { #F -R|--restart-apps "true", whether to force an app restart declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 - declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}" + declare SERVICE="$1" UPGRADE_FLAGS_LIST="${@:2}" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" verify_service_name "$SERVICE" From 9fac5a4ad4862a75445a9898cd2aa12921e731aa Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:32:33 -0400 Subject: [PATCH 22/33] Release 1.4.7 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index ae7fb20..6ef2418 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.6" +version = "1.4.7" [plugin.config] From 30b033ee9ddf59ceb68b1c0fa5e4289840cb3bc4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:47:46 -0400 Subject: [PATCH 23/33] fix: respect various ways of not wanting 'fancy' output. Closes dokku/dokku-daemon#19 Closes dokku/dokku-daemon#22 --- help-functions | 66 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/help-functions b/help-functions index 6752433..d5c5be6 100755 --- a/help-functions +++ b/help-functions @@ -28,14 +28,14 @@ fn-help() { fn-help-all() { declare CMD="$1" SUBCOMMAND="$2" - local CMD_OUTPUT BLUE BOLD FULL_OUTPUT NORMAL + local CMD_OUTPUT BLUE BOLD FULL_OUTPUT NORMAL FULL_OUTPUT=true if [[ "$CMD" = "$PLUGIN_COMMAND_PREFIX:help" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX:default" ]] ; then - BOLD="$(tput bold)" - NORMAL="\033[m" - BLUE="\033[0;34m" - CYAN="\033[1;36m" + BOLD="$(fn-help-fancy-tput bold)" + NORMAL="$(fn-help-fancy-color "\033[m")" + BLUE="$(fn-help-fancy-color "\033[0;34m")" + CYAN="$(fn-help-fancy-color "\033[1;36m")" if [[ -n "$SUBCOMMAND" ]] && [[ "$SUBCOMMAND" != "--all" ]]; then fn-help-contents-subcommand "$SUBCOMMAND" "$FULL_OUTPUT" return "$?" @@ -95,12 +95,12 @@ fn-help-contents-subcommand() { desc="$(grep desc "$CLEAN_FILE" | head -1)" eval "$desc" - BLUE="\033[0;34m" - BOLD="$(tput bold)" - CYAN="\033[1;36m" - NORMAL="\033[m" - LIGHT_GRAY="\033[2;37m" - LIGHT_RED="\033[1;31m" + BLUE="$(fn-help-fancy-color "\033[0;34m")" + BOLD="$(fn-help-fancy-tput bold)" + CYAN="$(fn-help-fancy-color "\033[1;36m")" + NORMAL="$(fn-help-fancy-color "\033[m")" + LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")" + LIGHT_RED="$(fn-help-fancy-color "\033[1;31m")" CMD_OUTPUT="$(echo -e " ${PLUGIN_COMMAND_PREFIX}${cmd_line}, ${LIGHT_GRAY}${desc}${NORMAL}")" if [[ "$FULL_OUTPUT" != "true" ]]; then echo "$CMD_OUTPUT" @@ -139,6 +139,26 @@ fn-help-contents-subcommand() { return 0 } +fn-help-fancy-tput() { + declare desc="A wrapper around tput" + + if [[ -z "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + return + fi + + tput "$@" +} + +fn-help-fancy-color() { + declare desc="A wrapper around colors" + + if [[ -z "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + return + fi + + echo "$@" +} + fn-help-list-example() { # shellcheck disable=SC2034 declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content" @@ -153,8 +173,8 @@ fn-help-subcommand-args() { local argline arglist args argpos BLUE NORMAL if [[ "$FULL_OUTPUT" == "true" ]]; then - BLUE="\033[0;34m" - NORMAL="\033[m" + BLUE="$(fn-help-fancy-color "\033[0;34m")" + NORMAL="$(fn-help-fancy-color "\033[m")" fi argline=$(grep declare "$FUNC_FILE" | grep -v "declare desc" | head -1 || true) arglist=($(echo -e "${argline// /"\n"}" | awk -F= '/=/{print ""$1""}')) @@ -199,12 +219,12 @@ fn-help-subcommand-example() { return 0 fi - BOLD="$(tput bold)" + BOLD="$(fn-help-fancy-tput bold)" LAST_LINE="" - LIGHT_GRAY="\033[2;37m" - OTHER_GRAY="\033[7;37m" + LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")" + OTHER_GRAY="$(fn-help-fancy-color "\033[7;37m")" NEWLINE="" - NORMAL="\033[m" + NORMAL="$(fn-help-fancy-color "\033[m")" _fn-help-apply-shell-expansion "$EXAMPLE" | while read -r line; do line="$(echo "$line" | cut -c 4-)" if [[ "$line" == export* ]] || [[ "$line" == dokku* ]]; then @@ -234,10 +254,10 @@ fn-help-subcommand-list-args() { return 0 fi - NORMAL="\033[m" - LIGHT_GRAY="\033[2;37m" + NORMAL="$(fn-help-fancy-color "\033[m")" + LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")" - _fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do + _fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do echo -e "$(echo "$line" | cut -d',' -f1),${LIGHT_GRAY}$(echo "$line" | cut -d',' -f2-)${NORMAL}" done } @@ -251,10 +271,10 @@ fn-help-subcommand-list-flags() { return 0 fi - NORMAL="\033[m" - LIGHT_GRAY="\033[2;37m" + NORMAL="$(fn-help-fancy-color "\033[m")" + LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")" - _fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do + _fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do echo -e "$(echo "$line" | cut -d',' -f1),${LIGHT_GRAY}$(echo "$line" | cut -d',' -f2-)${NORMAL}" done } From b68ae2d0bdd018959b428c396c20c4503075901b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:48:52 -0400 Subject: [PATCH 24/33] Release 1.4.8 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 6ef2418..58ce102 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.7" +version = "1.4.8" [plugin.config] From 86a032a32f488283ab3d1c4b83b02bbc662680ed Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:54:08 -0400 Subject: [PATCH 25/33] feat: allow removal of header from :list subcommand --- common-functions | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common-functions b/common-functions index c5d3d5d..21c89e7 100755 --- a/common-functions +++ b/common-functions @@ -440,7 +440,11 @@ service_list() { if [[ -z $SERVICES ]]; then dokku_log_warn "There are no $PLUGIN_SERVICE services" else - LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n" + LIST="" + if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then + LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n" + fi + for SERVICE in $SERVICES; do LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_linked_apps "$SERVICE")\n" done From 3641c2dc7672b1e69e62c02d160ad6f7cb327dfd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Oct 2018 23:54:46 -0400 Subject: [PATCH 26/33] Release 1.4.9 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 58ce102..3282a6b 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.8" +version = "1.4.9" [plugin.config] From 621e0189998a62205194ab75f1d3bc34a09663d5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 00:04:52 -0400 Subject: [PATCH 27/33] feat: skip upgrade if service is already up to date --- subcommands/upgrade | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subcommands/upgrade b/subcommands/upgrade index ba27943..37cd4c6 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -30,7 +30,13 @@ service-upgrade-cmd() { dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist" fi - dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + if [[ "$(service_version "$SERVICE")" == "$NEW_PLUGIN_IMAGE_TAG" ]]; then + dokku_log_info1 "Service $SERVICE already running $NEW_PLUGIN_IMAGE_TAG" + return + fi + + dokku_log_info2 "Upgrading $SERVICE to $NEW_PLUGIN_IMAGE_TAG" if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then dokku_log_info2 "Stopping all linked services" for app in $(service_linked_apps "$SERVICE"); do From 4948e2b91dc5e49395a5bd8444d9165a7848316e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 00:05:32 -0400 Subject: [PATCH 28/33] Release 1.4.10 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 3282a6b..e1a3b4b 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.9" +version = "1.4.10" [plugin.config] From 1542a9556fd697db70359d34ff19f288d8e35145 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 14:16:47 -0400 Subject: [PATCH 29/33] fix: correct issues in upgrade and fix tests --- common-functions | 1 + subcommands/upgrade | 4 ++-- tests/test_helper.bash | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 tests/test_helper.bash diff --git a/common-functions b/common-functions index 21c89e7..f2a9716 100755 --- a/common-functions +++ b/common-functions @@ -283,6 +283,7 @@ service_container_rm() { [[ -z "$ID" ]] && return 0 dokku_log_verbose_quiet "Removing container" + docker update --restart=no "$SERVICE_NAME" > /dev/null 2>&1 if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then dokku_log_fail "Unable to remove container for service $SERVICE" fi diff --git a/subcommands/upgrade b/subcommands/upgrade index 37cd4c6..76f1a9b 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -21,8 +21,6 @@ service-upgrade-cmd() { verify_service_name "$SERVICE" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" - local ID="$(cat "$SERVICE_ROOT/ID")" - is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running" service_parse_args "${@:2}" @@ -40,6 +38,7 @@ service-upgrade-cmd() { if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then dokku_log_info2 "Stopping all linked services" for app in $(service_linked_apps "$SERVICE"); do + [[ "$app" == "-" ]] && continue ps_stop "$app" done fi @@ -51,6 +50,7 @@ service-upgrade-cmd() { if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then dokku_log_info2 "Starting all linked services" for app in $(service_linked_apps "$SERVICE"); do + [[ "$app" == "-" ]] && continue ps_start "$app" done fi diff --git a/tests/test_helper.bash b/tests/test_helper.bash old mode 100644 new mode 100755 index 9aa1026..39b6092 --- a/tests/test_helper.bash +++ b/tests/test_helper.bash @@ -1,5 +1,4 @@ #!/usr/bin/env bash -export DOKKU_QUIET_OUTPUT=1 export DOKKU_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku" export DOKKU_VERSION=${DOKKU_VERSION:-"master"} export PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin:$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku:$PATH" From c32f4e92a1a8a12e4cb808ff1ac574ab325f889e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 14:20:03 -0400 Subject: [PATCH 30/33] fix: correct issue where help output isnt colorized by default --- help-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/help-functions b/help-functions index d5c5be6..51ae35b 100755 --- a/help-functions +++ b/help-functions @@ -142,7 +142,7 @@ fn-help-contents-subcommand() { fn-help-fancy-tput() { declare desc="A wrapper around tput" - if [[ -z "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then return fi @@ -152,7 +152,7 @@ fn-help-fancy-tput() { fn-help-fancy-color() { declare desc="A wrapper around colors" - if [[ -z "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then return fi From 98edfb9bb2c4142e254b7ed90ee7270c739af35b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 14:53:21 -0400 Subject: [PATCH 31/33] Release 1.4.11 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index e1a3b4b..58d14e7 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku postgres service plugin" -version = "1.4.10" +version = "1.4.11" [plugin.config] From c276507d3bd17c8b972f966c8fafda86a2fd69f4 Mon Sep 17 00:00:00 2001 From: ilopatin Date: Thu, 18 Oct 2018 11:30:47 +0300 Subject: [PATCH 32/33] fix: remove dokkupaas/s3backup container after backup --- common-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-functions b/common-functions index f2a9716..d9c0b58 100755 --- a/common-functions +++ b/common-functions @@ -183,7 +183,7 @@ service_backup() { fi # shellcheck disable=SC2086 - docker run $BACKUP_PARAMETERS dokkupaas/s3backup:0.8.0 + docker run --rm $BACKUP_PARAMETERS dokkupaas/s3backup:0.8.0 } service_backup_auth() { From 1465f6f3ca2916af30f35fb84998fd8a5a095032 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 2 Dec 2018 04:33:58 -0500 Subject: [PATCH 33/33] fix: correct documentation around the passphrase parameter Closes dokku/dokku-mysql#101 --- README.md | 2 +- subcommands/backup-set-encryption | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index df20416..33939b2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ postgres:backup-auth ( Removes backup authentication for the postgres service postgres:backup-schedule Schedules a backup of the postgres service postgres:backup-schedule-cat Show the backup schedule for the service -postgres:backup-set-encryption Sets up GPG encryption for future backups of the postgres service +postgres:backup-set-encryption Set a GPG passphrase for backups postgres:backup-unschedule Unschedules the backup of the postgres service postgres:backup-unset-encryption Removes backup encryption for future backups of the postgres service postgres:clone Create container then copy data from into diff --git a/subcommands/backup-set-encryption b/subcommands/backup-set-encryption index 175d716..dce3620 100755 --- a/subcommands/backup-set-encryption +++ b/subcommands/backup-set-encryption @@ -5,19 +5,19 @@ source "$PLUGIN_BASE_PATH/common/functions" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" service-backup-set-encryption-cmd() { - #E set a GPG encryption key for backups + #E set a GPG passphrase for backups #E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lolipop #A service, service to run command against - #A encryption-key, a GPG encryption key + #A passphrase, a GPG-compatible passphrase declare desc="sets encryption for all future backups of $PLUGIN_SERVICE service" local cmd="$PLUGIN_COMMAND_PREFIX:backup-set-encryption" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 - declare SERVICE="$1" ENCRYPTION_KEY="$2" + declare SERVICE="$1" PASSPHRASE="$2" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" - [[ -z "$ENCRYPTION_KEY" ]] && dokku_log_fail "Please specify a GPG encryption key" + [[ -z "$PASSPHRASE" ]] && dokku_log_fail "Please specify a GPG backup passphrase" verify_service_name "$SERVICE" - service_backup_set_encryption "$SERVICE" "$ENCRYPTION_KEY" + service_backup_set_encryption "$SERVICE" "$PASSPHRASE" } service-backup-set-encryption-cmd "$@"