28 lines
1.2 KiB
Bash
Executable File
28 lines
1.2 KiB
Bash
Executable File
#!/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-connect-admin-cmd() {
|
|
#E connect with the admin user to the service via the $PLUGIN_COMMAND_PREFIX connection tool
|
|
#E dokku $PLUGIN_COMMAND_PREFIX:connect-admin lollipop
|
|
#A service, service to run command against
|
|
declare desc="connect via mongo to a $PLUGIN_SERVICE service as admin user"
|
|
local cmd="$PLUGIN_COMMAND_PREFIX:connect-admin" argv=("$@")
|
|
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
|
declare SERVICE="$1"
|
|
|
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
|
verify_service_name "$SERVICE"
|
|
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
|
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
|
PASSWORD="$(service_root_password "$SERVICE")"
|
|
has_tty && SERVICE_TTY_OPTS="-t"
|
|
|
|
docker exec --env=LANG=C.UTF-8 --env=LC_ALL=C.UTF-8 -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mongo -u admin -p "$PASSWORD" --authenticationDatabase admin "$SERVICE"
|
|
}
|
|
|
|
service-connect-admin-cmd "$@"
|