Conform to function declaration standards
- declare desc variable - declare all positional arguments - set the cmd - properly handle DOKKU_APP_NAME
This commit is contained in:
@@ -5,14 +5,18 @@ source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
postgres-destroy-cmd() {
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$2"
|
||||
SERVICE="$2"; SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||
declare desc="delete the $PLUGIN_SERVICE service and stop its container if there are no links left"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:destroy" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" FORCE_DESTROY="$2"
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||
|
||||
[[ -s "$LINKS_FILE" ]] && dokku_log_fail "Cannot delete linked service"
|
||||
|
||||
[[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
|
||||
[[ "$FORCE_DESTROY" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
|
||||
if [[ -z "$DOKKU_APPS_FORCE_DELETE" ]]; then
|
||||
dokku_log_warn "WARNING: Potentially Destructive Action"
|
||||
dokku_log_warn "This command will destroy $SERVICE $PLUGIN_SERVICE service."
|
||||
@@ -28,6 +32,7 @@ postgres-destroy-cmd() {
|
||||
|
||||
dokku_log_info1 "Deleting $SERVICE"
|
||||
if [[ -n $(docker ps -aq -f name="$SERVICE_NAME") ]]; then
|
||||
dokku_log_verbose_quiet "Deleting container data"
|
||||
service_stop "$SERVICE"
|
||||
sleep 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user