Reduce duplication
This commit is contained in:
1 parent
73e0a6bb0a
commit
0c2aa494ae
1 file changed
+2
-12
@@ -908,29 +908,19 @@ container_weave_addrs() {
|
|||||||
|
|
||||||
# Check that a container for component $1 named $2 with image $3 is not running
|
# Check that a container for component $1 named $2 with image $3 is not running
|
||||||
check_not_running() {
|
check_not_running() {
|
||||||
case $(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) in
|
RUN_STATUS=$(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) || true
|
||||||
|
case ${RUN_STATUS%:*} in
|
||||||
"true restarting $3")
|
"true restarting $3")
|
||||||
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
|
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
"true restarting $3:"*)
|
|
||||||
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
"true "*" $3")
|
"true "*" $3")
|
||||||
echo "$2 is already running." >&2
|
echo "$2 is already running." >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
"true "*" $3:"*)
|
|
||||||
echo "$2 is already running." >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
"false "*" $3")
|
"false "*" $3")
|
||||||
docker rm $2 >/dev/null
|
docker rm $2 >/dev/null
|
||||||
;;
|
;;
|
||||||
"false "*" $3:"*)
|
|
||||||
docker rm $2 >/dev/null
|
|
||||||
;;
|
|
||||||
true*)
|
true*)
|
||||||
echo "Found another running container named '$2'. Aborting." >&2
|
echo "Found another running container named '$2'. Aborting." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in new issue
Block a user