diff --git a/bin/release b/bin/release index e72678b8..514074a5 100755 --- a/bin/release +++ b/bin/release @@ -47,6 +47,8 @@ build() { ## (library versions?) sed -i "/var version = / c\var version = \"$VERSION\"" weaver/main.go + sed -i "/var version = / c\var version = \"$VERSION\"" weavedns/main.go + sed -i "/SCRIPT_VERSION=/ c\SCRIPT_VERSION=\"$VERSION\"" ./weave make \ WEAVER_IMAGE=$DOCKERHUB_USER/weave \ WEAVEDNS_IMAGE=$DOCKERHUB_USER/weavedns diff --git a/weave b/weave index 1b010a6e..2a9f1a6f 100755 --- a/weave +++ b/weave @@ -1,6 +1,8 @@ #!/bin/sh set -e +SCRIPT_VERSION="(unreleased version)" + usage() { echo "Usage:" echo "weave launch [-password | -passwordfile ] ..." @@ -479,14 +481,21 @@ case "$COMMAND" in ;; version) [ $# -eq 0 ] || usage - # Try the running container first; if no luck try the image + echo weave script $SCRIPT_VERSION if ! DOCKERIMAGE=$(docker inspect --format='{{ .Image }}' $CONTAINER_NAME 2>/dev/null) ; then if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' $IMAGE 2>/dev/null) ; then echo "Unable to find $IMAGE image." >&2 exit 1 fi fi - docker images --no-trunc | grep $DOCKERIMAGE | grep -v latest | tr -s ' ' | cut -d ' ' -f 2 + docker run --rm $DOCKERIMAGE --version + if ! DOCKERIMAGE=$(docker inspect --format='{{ .Image }}' $DNS_CONTAINER_NAME 2>/dev/null) ; then + if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' $DNS_IMAGE 2>/dev/null) ; then + echo "Unable to find $DNS_IMAGE image." >&2 + exit 1 + fi + fi + docker run --rm $DOCKERIMAGE --version ;; run) [ $# -gt 0 ] || usage diff --git a/weavedns/main.go b/weavedns/main.go index b06e7f1b..1185dc75 100644 --- a/weavedns/main.go +++ b/weavedns/main.go @@ -2,24 +2,30 @@ package main import ( "flag" + "fmt" weavedns "github.com/zettio/weave/nameserver" weavenet "github.com/zettio/weave/net" + "io" "io/ioutil" "net" "os" ) +var version = "(unreleased version)" + func main() { var ( - ifaceName string - apiPath string - dnsPort int - httpPort int - wait int - watch bool - debug bool + justVersion bool + ifaceName string + apiPath string + dnsPort int + httpPort int + wait int + watch bool + debug bool ) + flag.BoolVar(&justVersion, "version", false, "print version and exit") flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast") flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "Path to Docker API socket") flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up") @@ -29,6 +35,11 @@ func main() { flag.BoolVar(&debug, "debug", false, "output debugging info to stderr") flag.Parse() + if justVersion { + io.WriteString(os.Stdout, fmt.Sprintf("weavedns %s\n", version)) + os.Exit(0) + } + debugOut := ioutil.Discard if debug { debugOut = os.Stderr