Skip to content

Commit

Permalink
docker compose plugin and legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
casperklein committed Dec 20, 2023
1 parent 540a3e4 commit 5b27d3a
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions mailctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

# SETUP --------------------------------------------------------------

DIR=/mail # compose.yaml directory
CONTAINER=mail # DMS container name
TIMEOUT=3600 # a lot of time for a graceful container stop
DIR=/mail # compose.yaml directory
CONTAINER=mail # DMS container name
TIMEOUT=3600 # a lot of time for a graceful container stop

# DOCKER_COMPOSE="docker-compose" # lagacy docker-compose
DOCKER_COMPOSE="docker compose" # compose plugin

# --------------------------------------------------------------------

Expand All @@ -29,10 +32,17 @@ _checkBin() {
exit 1
} >&2
done

# docker compose
$DOCKER_COMPOSE version &>/dev/null || {
echo "Error: '$DOCKER_COMPOSE' not available."
echo
exit 1
} >&2
}

# Dependencies
_checkBin "cat" "cut" "docker" "docker-compose" "fold" "jq" "printf" "sed" "tail" "tput" "tr"
_checkBin "cat" "cut" "docker" "fold" "jq" "printf" "sed" "tail" "tput" "tr"

# Check if container is running
# Skip check, if first argument is empty, "status", "start", "stop" or "restart"
Expand Down Expand Up @@ -134,17 +144,17 @@ case "${1:-}" in
exit
fi
# If container is stopped, remove container / network etc.
docker-compose down -t "$TIMEOUT" 2>/dev/null || true
docker-compose up -d
$DOCKER_COMPOSE down -t "$TIMEOUT" 2>/dev/null || true
$DOCKER_COMPOSE up -d
;;

stop) # Stop container
docker-compose down -t "$TIMEOUT"
$DOCKER_COMPOSE down -t "$TIMEOUT"
;;

resta*) # Restart container
docker-compose down -t "$TIMEOUT"
docker-compose up -d
$DOCKER_COMPOSE down -t "$TIMEOUT"
$DOCKER_COMPOSE up -d
;;

setup) # Invoke 'setup.sh'
Expand Down

0 comments on commit 5b27d3a

Please sign in to comment.