Skip to content

Commit 5b27d3a

Browse files
committed
docker compose plugin and legacy support
1 parent 540a3e4 commit 5b27d3a

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

mailctl

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
# SETUP --------------------------------------------------------------
44

5-
DIR=/mail # compose.yaml directory
6-
CONTAINER=mail # DMS container name
7-
TIMEOUT=3600 # a lot of time for a graceful container stop
5+
DIR=/mail # compose.yaml directory
6+
CONTAINER=mail # DMS container name
7+
TIMEOUT=3600 # a lot of time for a graceful container stop
8+
9+
# DOCKER_COMPOSE="docker-compose" # lagacy docker-compose
10+
DOCKER_COMPOSE="docker compose" # compose plugin
811

912
# --------------------------------------------------------------------
1013

@@ -29,10 +32,17 @@ _checkBin() {
2932
exit 1
3033
} >&2
3134
done
35+
36+
# docker compose
37+
$DOCKER_COMPOSE version &>/dev/null || {
38+
echo "Error: '$DOCKER_COMPOSE' not available."
39+
echo
40+
exit 1
41+
} >&2
3242
}
3343

3444
# Dependencies
35-
_checkBin "cat" "cut" "docker" "docker-compose" "fold" "jq" "printf" "sed" "tail" "tput" "tr"
45+
_checkBin "cat" "cut" "docker" "fold" "jq" "printf" "sed" "tail" "tput" "tr"
3646

3747
# Check if container is running
3848
# Skip check, if first argument is empty, "status", "start", "stop" or "restart"
@@ -134,17 +144,17 @@ case "${1:-}" in
134144
exit
135145
fi
136146
# If container is stopped, remove container / network etc.
137-
docker-compose down -t "$TIMEOUT" 2>/dev/null || true
138-
docker-compose up -d
147+
$DOCKER_COMPOSE down -t "$TIMEOUT" 2>/dev/null || true
148+
$DOCKER_COMPOSE up -d
139149
;;
140150

141151
stop) # Stop container
142-
docker-compose down -t "$TIMEOUT"
152+
$DOCKER_COMPOSE down -t "$TIMEOUT"
143153
;;
144154

145155
resta*) # Restart container
146-
docker-compose down -t "$TIMEOUT"
147-
docker-compose up -d
156+
$DOCKER_COMPOSE down -t "$TIMEOUT"
157+
$DOCKER_COMPOSE up -d
148158
;;
149159

150160
setup) # Invoke 'setup.sh'

0 commit comments

Comments
 (0)