Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Reduce duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Dec 22, 2015
1 parent 5292a8f commit 5d515fb
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions weave
Original file line number Diff line number Diff line change
Expand Up @@ -915,29 +915,19 @@ container_weave_addrs() {

# Check that a container named $1 with image $2 for component $3 is not running
check_not_running() {
case $(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $1 2>/dev/null) in
RUN_STATUS=$(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $1 2>/dev/null) || true
case ${RUN_STATUS%:*} in
"true restarting $2")
echo "$1 is restarting; you can stop it with 'weave stop-$3'" >&2
exit 1
;;
"true restarting $2:"*)
echo "$1 is restarting; you can stop it with 'weave stop-$3'" >&2
exit 1
;;
"true "*" $2")
echo "$1 is already running." >&2
exit 1
;;
"true "*" $2:"*)
echo "$1 is already running." >&2
exit 1
;;
"false "*" $2")
docker rm $1 >/dev/null
;;
"false "*" $2:"*)
docker rm $1 >/dev/null
;;
true*)
echo "Found another running container named '$1'. Aborting." >&2
exit 1
Expand Down

0 comments on commit 5d515fb

Please sign in to comment.