diff --git a/kolabctl b/kolabctl index 99b65417..a181cf35 100755 --- a/kolabctl +++ b/kolabctl @@ -1,79 +1,91 @@ #!/bin/bash CONFIG="config.prod" HOST="kolab.local" BRANCH="master" kolab__deploy() { echo "Please enter your new admin password for the admin@$HOST user:" read -r ADMIN_PASSWORD echo "Deploying $CONFIG from branch $BRANCH on $HOST" command env KOLAB_GIT_REF=$BRANCH HOST=$HOST ADMIN_PASSWORD="$ADMIN_PASSWORD" bin/configure.sh "$CONFIG" command env ADMIN_PASSWORD="$ADMIN_PASSWORD" bin/deploy.sh } kolab__start() { command bin/start.sh } kolab__stop() { command bin/stop.sh } kolab__update() { command bin/update.sh } kolab__backup() { command bin/backup.sh } kolab__restore() { command bin/restore.sh } kolab__selfcheck() { command bin/selfcheck.sh } +kolab__ps() { + command docker compose ps +} + +kolab__exec() { + command docker compose exec -ti $@ +} + +kolab__cyradm() { + # command docker compose exec -ti imap cyradm --auth PLAIN -u admin@kolab.local -w simple123 --port 11143 localhost + if [[ "$@" ]]; then + command docker compose exec -ti imap echo "$@" | cyradm --auth PLAIN -u $(grep IMAP_ADMIN_LOGIN .env | cut -d '=' -f 2 ) -w $(grep IMAP_ADMIN_PASSWORD .env | cut -d '=' -f 2 ) --port 11143 localhost + else + command docker compose exec -ti imap cyradm --auth PLAIN -u $(grep IMAP_ADMIN_LOGIN .env | cut -d '=' -f 2 ) -w $(grep IMAP_ADMIN_PASSWORD .env | cut -d '=' -f 2 ) --port 11143 localhost + fi +} + +kolab__shell() { + command docker compose exec -ti $1 /bin/bash +} + +kolab__logs() { + command docker compose logs -f $1 +} + + kolab__help() { cat </dev/null 2>&1; then - "kolab__$cmdname" "$@" - else - command "$cmdname" "$@" # call the **real** yum command - fi -} - -# if the functions above are sourced into an interactive interpreter, the user can -# just call "kolab deploy" or "kolab start" with no further code needed. - -# if invoked as a script rather than sourced, call function named on argv via the below; -# note that this must be the first operation other than a function definition -# for $_ to successfully distinguish between sourcing and invocation: -# [[ $_ != $0 ]] && return +cmdname=$1 +shift # make sure we actually *did* get passed a valid function name -if declare -f "kolab__$1" >/dev/null 2>&1; then - "kolab__$1" "${@:1}" +if declare -f "kolab__$cmdname" >/dev/null 2>&1; then + "kolab__$cmdname" "${@:1}" else - echo "Function $1 not recognized" >&2 + echo "Function $cmdname not recognized" >&2 kolab__help exit 1 fi