New --with-dns/--without-dns behaviour in weave script
This commit is contained in:
1 parent
8873d69b77
commit
fdce84d9d9
1 file changed
+29
-10
@@ -29,10 +29,11 @@ usage() {
|
|||||||
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
|
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
|
||||||
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
|
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
|
||||||
echo "weave launch-dns [<addr>]"
|
echo "weave launch-dns [<addr>]"
|
||||||
echo "weave launch-proxy [-D <endpoint>] [-H <endpoint>] [--with-dns|--without-dns] [--with-ipam]"
|
echo "weave launch-proxy [-D <endpoint>] [-H <endpoint>]"
|
||||||
|
echo " [--with-dns | --without-dns] [--with-ipam]"
|
||||||
echo "weave connect [--replace] [<peer> ...]"
|
echo "weave connect [--replace] [<peer> ...]"
|
||||||
echo "weave forget <peer> ..."
|
echo "weave forget <peer> ..."
|
||||||
echo "weave run [--with-dns] [<addr> ...] <docker run args> ..."
|
echo "weave run [--with-dns | --without-dns] [<addr> ...] <docker run args> ..."
|
||||||
echo "weave start [<addr> ...] <container_id>"
|
echo "weave start [<addr> ...] <container_id>"
|
||||||
echo "weave attach [<addr> ...] <container_id>"
|
echo "weave attach [<addr> ...] <container_id>"
|
||||||
echo "weave detach [<addr> ...] <container_id>"
|
echo "weave detach [<addr> ...] <container_id>"
|
||||||
@@ -119,6 +120,14 @@ collect_ip_args() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dns_arg_count() {
|
||||||
|
if [ "$1" = "--with-dns" -o "$1" = "--without-dns" ]; then
|
||||||
|
echo 1
|
||||||
|
else
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# "run" is a special case because we want to use docker directly,
|
# "run" is a special case because we want to use docker directly,
|
||||||
# rather than the docker in $EXEC_IMAGE remotely. That's because we
|
# 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
|
# are passing arbitrary arguments on to docker run, and we can't rely
|
||||||
@@ -126,10 +135,10 @@ collect_ip_args() {
|
|||||||
if [ "$1" = "run" ] ; then
|
if [ "$1" = "run" ] ; then
|
||||||
shift 1
|
shift 1
|
||||||
check_docker_version
|
check_docker_version
|
||||||
if [ "$1" = "--with-dns" ] ; then
|
if [ "$1" != "--without-dns" ] ; then
|
||||||
shift 1
|
DNS_ARGS=$(exec_remote dns-args "$@" || true)
|
||||||
DNS_ARGS=$(exec_remote dns-args "$@")
|
|
||||||
fi
|
fi
|
||||||
|
shift $(dns_arg_count "$@")
|
||||||
collect_cidr_args "$@"
|
collect_cidr_args "$@"
|
||||||
shift $CIDR_ARG_COUNT
|
shift $CIDR_ARG_COUNT
|
||||||
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run $DNS_ARGS -d "$@")
|
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run $DNS_ARGS -d "$@")
|
||||||
@@ -631,7 +640,7 @@ dns_args() {
|
|||||||
# versions prior to 1.3.0 fail to include the domain when
|
# versions prior to 1.3.0 fail to include the domain when
|
||||||
# setting the hostname, so lookups for non-fully-qualified
|
# setting the hostname, so lookups for non-fully-qualified
|
||||||
# names fail.
|
# names fail.
|
||||||
echo "ERROR: The '--with-dns' option requires Docker 1.3.0 or later; you are running $DOCKER_VERSION" >&2
|
echo "ERROR: Need Docker 1.3.0 or later to configure container DNS; you are running $DOCKER_VERSION" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
docker_bridge_ip
|
docker_bridge_ip
|
||||||
@@ -639,6 +648,8 @@ dns_args() {
|
|||||||
DNS_SEARCH_ARG="--dns-search=."
|
DNS_SEARCH_ARG="--dns-search=."
|
||||||
NAME_ARG=""
|
NAME_ARG=""
|
||||||
HOSTNAME_SPECIFIED=
|
HOSTNAME_SPECIFIED=
|
||||||
|
WITH_DNS=
|
||||||
|
WITHOUT_DNS=
|
||||||
while [ $# -gt 0 ] ; do
|
while [ $# -gt 0 ] ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--dns-search=*)
|
--dns-search=*)
|
||||||
@@ -654,9 +665,19 @@ dns_args() {
|
|||||||
-h|--hostname|--hostname=*)
|
-h|--hostname|--hostname=*)
|
||||||
HOSTNAME_SPECIFIED=1
|
HOSTNAME_SPECIFIED=1
|
||||||
;;
|
;;
|
||||||
|
--with-dns)
|
||||||
|
WITH_DNS=1
|
||||||
|
;;
|
||||||
|
--without-dns)
|
||||||
|
WITHOUT_DNS=1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
[ -n "$WITHOUT_DNS" ] && return 0
|
||||||
|
if [ -z "$WITH_DNS" ] ; then
|
||||||
|
check_running $DNS_CONTAINER_NAME 2>/dev/null || return 0
|
||||||
|
fi
|
||||||
DNS_ARGS="$DNS_ARG $DNS_SEARCH_ARG"
|
DNS_ARGS="$DNS_ARG $DNS_SEARCH_ARG"
|
||||||
if [ -n "$NAME_ARG" -a -z "$HOSTNAME_SPECIFIED" ] ; then
|
if [ -n "$NAME_ARG" -a -z "$HOSTNAME_SPECIFIED" ] ; then
|
||||||
DOMAIN=$(call_dns GET /domain 2>/dev/null) || DOMAIN=weave.local.
|
DOMAIN=$(call_dns GET /domain 2>/dev/null) || DOMAIN=weave.local.
|
||||||
@@ -1071,10 +1092,8 @@ case "$COMMAND" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
run)
|
run)
|
||||||
if [ "$1" = "--with-dns" ] ; then
|
dns_args "$@"
|
||||||
shift 1
|
shift $(dns_arg_count "$@")
|
||||||
dns_args "$@"
|
|
||||||
fi
|
|
||||||
collect_cidr_args "$@"
|
collect_cidr_args "$@"
|
||||||
shift $CIDR_ARG_COUNT
|
shift $CIDR_ARG_COUNT
|
||||||
CONTAINER=$(docker run $DNS_ARGS -d "$@")
|
CONTAINER=$(docker run $DNS_ARGS -d "$@")
|
||||||
|
|||||||
Reference in new issue
Block a user