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

Commit

Permalink
deal with weave --help|help locally
Browse files Browse the repository at this point in the history
thus making them unaffected by docker breakages

Fixes #1322.
  • Loading branch information
rade committed Aug 18, 2015
1 parent e1d07aa commit dbc25dc
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions weave
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ usage() {
cat >&2 <<EOF
Usage:
weave --help | help
weave setup
weave version
weave launch [--password <password>] [--nickname <nickname>]
Expand Down Expand Up @@ -70,7 +71,7 @@ where <peer> = <ip_address_or_fqdn>[:<port>]
<endpoint> = [tcp://][<ip_address>]:<port> | [unix://]/path/to/socket
<peer_id> = <nickname> or weave internal peer ID
EOF
exit 1
exit ${1:-1}
}

exec_remote() {
Expand Down Expand Up @@ -161,29 +162,42 @@ dns_arg_count() {
fi
}

# "--help|help" are special because we always want to process them
# locally.
#
# "run" is a special case because we want to use docker directly,
# rather than the docker in $EXEC_IMAGE remotely. That's because we
# are passing arbitrary arguments on to docker run, and we can't rely
# on our baked-in docker to support those arguments.
if [ "$1" = "run" ] ; then
shift 1
check_docker_version
if [ "$1" != "--without-dns" ] ; then
DNS_ARGS=$(exec_remote dns-args "$@" || true)
fi
shift $(dns_arg_count "$@")
collect_cidr_args "$@"
shift $CIDR_ARG_COUNT
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
exec_remote attach $CIDR_ARGS --or-die $CONTAINER >/dev/null
echo $CONTAINER
exit 0
elif [ "$1" != "--local" ] ; then
exec_remote "$@"
exit $?
fi
case "$1" in
--help|help)
;;
run)
shift 1
check_docker_version
if [ "$1" != "--without-dns" ] ; then
DNS_ARGS=$(exec_remote dns-args "$@" || true)
fi
shift $(dns_arg_count "$@")
collect_cidr_args "$@"
shift $CIDR_ARG_COUNT
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
exec_remote attach $CIDR_ARGS --or-die $CONTAINER >/dev/null
echo $CONTAINER
exit 0
;;
--local)
shift 1
;;
*)
exec_remote "$@"
exit $?
;;
esac

shift 1
if [ "$1" = "--help" -o "$1" = "help" ] ; then
usage 0
fi

BASE_IMAGE=$DOCKERHUB_USER/weave
IMAGE=$BASE_IMAGE:$IMAGE_VERSION
Expand Down

0 comments on commit dbc25dc

Please sign in to comment.