From 1efa88d773785786ceea757721221a6230b178e3 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Wed, 3 Jun 2015 10:48:00 +0000 Subject: [PATCH] Allow users to specify app and probe arguments. --- docker/entrypoint.sh | 25 +++++++++++++++++++++++-- docker/run-app | 2 +- docker/run-probe | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 788a4a163b..2d3a14a1cf 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,12 +1,16 @@ #!/bin/sh usage() { - echo "$0 --dns --hostname --searchpath " + echo "$0 --dns --hostname --searchpath --app.foo bar --probe.foo bar" exit 1 } # This script exists to modify the network settings in the scope containers # as docker doesn't allow it when started with --net=host + +APP_ARGS="" +PROBE_ARGS="" + while true; do case "$1" in --dns) @@ -19,12 +23,30 @@ while true; do SEARCHPATH="$2" shift 2 ;; + --app.*) + [ $# -gt 1 ] || usage + ARG_NAME=$(echo "$1" | sed 's/\-\-app\.//') + ARG_VALUE="$2" + shift 2 + APP_ARGS="$APP_ARGS -$ARG_NAME=$ARG_VALUE" + ;; + --probe.*) + [ $# -gt 1 ] || usage + ARG_NAME=$(echo "$1" | sed 's/\-\-probe\.//') + ARG_VALUE="$2" + shift 2 + PROBE_ARGS="$PROBE_ARGS -$ARG_NAME=$ARG_VALUE" + ;; *) break ;; esac done +mkdir -p /etc/weave +echo "$APP_ARGS" >/etc/weave/app.args +echo "$PROBE_ARGS" >/etc/weave/probe.args + if [ -n "$DNS_SERVER" -a -n "$SEARCHPATH" ]; then echo "domain $SEARCHPATH" >/etc/resolv.conf echo "search $SEARCHPATH" >>/etc/resolv.conf @@ -36,7 +58,6 @@ fi # using Weave DNS. We stick these in /etc/weave/probes # for the run-app script to pick up. MANUAL_PROBES=$@ -mkdir -p /etc/weave echo "$MANUAL_PROBES" >/etc/weave/probes exec /sbin/runsvdir /etc/service diff --git a/docker/run-app b/docker/run-app index df910e5f5c..bdd45c939a 100755 --- a/docker/run-app +++ b/docker/run-app @@ -1,3 +1,3 @@ #!/bin/sh -exec /home/weave/app $(cat /etc/weave/probes) +exec /home/weave/app $(cat /etc/weave/app.args) $(cat /etc/weave/probes) diff --git a/docker/run-probe b/docker/run-probe index fc9ec1bbbb..718c26ab80 100755 --- a/docker/run-probe +++ b/docker/run-probe @@ -1,3 +1,3 @@ #!/bin/sh -exec /home/weave/probe +exec /home/weave/probe $(cat /etc/weave/probe.args)