From 26be34feb71e4f14613f32e571f13b3f0333cd75 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 12 Jan 2018 12:26:34 -0500 Subject: [PATCH] feat: allow checking if a service exists --- README.md | 1 + subcommands/exists | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 subcommands/exists diff --git a/README.md b/README.md index 12e14e9..e7dcb02 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ mysql:connect Connect via mysql to a mysql service mysql:create Create a mysql service with environment variables mysql:destroy Delete the service, delete the data and stop its container if there are no links left mysql:enter [command] Enter or run a command in a running mysql service container +mysql:exists Check if the MySQL service exists mysql:export > Export a dump of the mysql service database mysql:expose [port] Expose a mysql service on custom port if provided (random port otherwise) mysql:import < Import a dump into the mysql service database diff --git a/subcommands/exists b/subcommands/exists new file mode 100755 index 0000000..93b6a99 --- /dev/null +++ b/subcommands/exists @@ -0,0 +1,20 @@ +#!/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-exists-cmd() { + #E here we check if the lolipop $PLUGIN_COMMAND_PREFIX service exists. + #E dokku $PLUGIN_COMMAND_PREFIX:exists lolipop + #A service, service to run command against + declare desc="check if the $PLUGIN_SERVICE service exists" + local cmd="$PLUGIN_COMMAND_PREFIX:exists" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + declare SERVICE="$1" + + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + verify_service_name "$SERVICE" + dokku_log_info1 "Service $SERVICE exists" +} + +service-exists-cmd "$@"