add mongo:admin command
This commit is contained in:
@@ -17,13 +17,14 @@ dokku plugin:install https://github.com/dokku/dokku-mongo.git mongo
|
|||||||
## commands
|
## commands
|
||||||
|
|
||||||
```
|
```
|
||||||
|
mongo:admin <name> Connect via telnet to a mongo service as admin user
|
||||||
mongo:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
mongo:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
||||||
mongo:connect <name> Connect via telnet to a mongo service
|
mongo:connect <name> Connect via telnet to a mongo service
|
||||||
mongo:create <name> Create a mongo service with environment variables
|
mongo:create <name> Create a mongo service with environment variables
|
||||||
mongo:destroy <name> Delete the service and stop its container if there are no links left
|
mongo:destroy <name> Delete the service and stop its container if there are no links left
|
||||||
mongo:export <name> > <file> Export a dump of the mongo service database
|
mongo:export <name> > <file> Export a dump of the mongo service database
|
||||||
mongo:expose <name> [port] Expose a mongo service on custom port if provided (random port otherwise)
|
mongo:expose <name> [port] Expose a mongo service on custom port if provided (random port otherwise)
|
||||||
mongo:import <name> < <file> Import a dump into the mongo service database
|
mongo:import <name> < <file> Import a dump into the mongo service database
|
||||||
mongo:info <name> Print the connection information
|
mongo:info <name> Print the connection information
|
||||||
mongo:link <name> <app> Link the mongo service to the app
|
mongo:link <name> <app> Link the mongo service to the app
|
||||||
mongo:list List all mongo services
|
mongo:list List all mongo services
|
||||||
|
|||||||
5
commands
5
commands
@@ -19,6 +19,10 @@ case "$1" in
|
|||||||
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/connect" "$@"
|
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/connect" "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
$PLUGIN_COMMAND_PREFIX:admin)
|
||||||
|
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/admin" "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:create)
|
$PLUGIN_COMMAND_PREFIX:create)
|
||||||
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/create" "$@"
|
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/create" "$@"
|
||||||
;;
|
;;
|
||||||
@@ -84,6 +88,7 @@ case "$1" in
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
|
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
|
||||||
cat<<help_content
|
cat<<help_content
|
||||||
|
$PLUGIN_COMMAND_PREFIX:admin <name>, Connect via mongo to a $PLUGIN_SERVICE service as admin user
|
||||||
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, Create container <new-name> then copy data from <name> into <new-name>
|
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, Create container <new-name> then copy data from <name> into <new-name>
|
||||||
$PLUGIN_COMMAND_PREFIX:connect <name>, Connect via mongo to a $PLUGIN_SERVICE service
|
$PLUGIN_COMMAND_PREFIX:connect <name>, Connect via mongo to a $PLUGIN_SERVICE service
|
||||||
$PLUGIN_COMMAND_PREFIX:create <name>, Create a $PLUGIN_SERVICE service
|
$PLUGIN_COMMAND_PREFIX:create <name>, Create a $PLUGIN_SERVICE service
|
||||||
|
|||||||
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