add mongo:admin command
This commit is contained in:
22
subcommands/admin
Normal file
22
subcommands/admin
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/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"
|
||||
|
||||
mongo-admin-cmd() {
|
||||
declare desc="connect via mongo to a $PLUGIN_SERVICE service as admin user"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:admin" 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"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||
PASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")"
|
||||
has_tty && SERVICE_TTY_OPTS="-t"
|
||||
|
||||
docker exec -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mongo -u admin -p "$PASSWORD" --authenticationDatabase admin "$SERVICE"
|
||||
}
|
||||
|
||||
mongo-admin-cmd "$@"
|
||||
Reference in New Issue
Block a user