refactor: extract weave docker image name

Thanks to @hesco for the suggestion.
This commit is contained in:
Matthias Radestock committed 2014-10-07 19:32:39 +01:00
1 parent 764ced41b8
commit 6d0df649fc
1 file changed
+6 -5
+6 -5
View File
@@ -29,6 +29,7 @@ command_exists () {
[ $# -gt 0 ] || usage [ $# -gt 0 ] || usage
IMAGE=zettio/weave
BRIDGE=weave BRIDGE=weave
CONTAINER_IFNAME=ethwe CONTAINER_IFNAME=ethwe
MTU=65535 MTU=65535
@@ -229,11 +230,11 @@ case "$COMMAND" in
IPADDR=$1 IPADDR=$1
shift 1 shift 1
case $(docker inspect --format '{{ .State.Running }} {{ .Config.Image }}' weave 2>/dev/null) in case $(docker inspect --format '{{ .State.Running }} {{ .Config.Image }}' weave 2>/dev/null) in
"true zettio/weave") "true $IMAGE")
echo "Weave is already running." >&2 echo "Weave is already running." >&2
exit 1 exit 1
;; ;;
"false zettio/weave") "false $IMAGE")
docker rm weave >/dev/null docker rm weave >/dev/null
;; ;;
true*) true*)
@@ -255,7 +256,7 @@ case "$COMMAND" in
# (eth0, wlan0, etc) so the name becomes stable across host # (eth0, wlan0, etc) so the name becomes stable across host
# restarts. # restarts.
MACADDR=`cat /sys/class/net/$BRIDGE/address` MACADDR=`cat /sys/class/net/$BRIDGE/address`
CONTAINER=$(docker run --privileged -d --name=weave -p 6783:6783/tcp -p 6783:6783/udp $WEAVE_DOCKER_ARGS zettio/weave -name $MACADDR "$@") CONTAINER=$(docker run --privileged -d --name=weave -p 6783:6783/tcp -p 6783:6783/udp $WEAVE_DOCKER_ARGS $IMAGE -name $MACADDR "$@")
with_container_netns attach $CONTAINER $IPADDR eth0 with_container_netns attach $CONTAINER $IPADDR eth0
echo $CONTAINER echo $CONTAINER
;; ;;
@@ -280,8 +281,8 @@ case "$COMMAND" in
version) version)
# Try the running container first; if no luck try the image # Try the running container first; if no luck try the image
if ! DOCKERIMAGE=$(docker inspect --format='{{ .Image }}' weave 2>/dev/null) ; then if ! DOCKERIMAGE=$(docker inspect --format='{{ .Image }}' weave 2>/dev/null) ; then
if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' zettio/weave 2>/dev/null) ; then if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' $IMAGE 2>/dev/null) ; then
echo "Unable to find zettio/weave image." >&2 echo "Unable to find $IMAGE image." >&2
exit 1 exit 1
fi fi
fi fi