Skip to content

Commit

Permalink
Merge pull request #169 from tomwilkie/153
Browse files Browse the repository at this point in the history
Allow users to specify app and probe arguments.
  • Loading branch information
tomwilkie committed Jun 3, 2015
2 parents a15f00a + 1efa88d commit 8f2ea9f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
25 changes: 23 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh

usage() {
echo "$0 --dns <IP> --hostname <NAME> --searchpath <SEARCHPATH>"
echo "$0 --dns <IP> --hostname <NAME> --searchpath <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)
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion docker/run-app
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion docker/run-probe
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

exec /home/weave/probe
exec /home/weave/probe $(cat /etc/weave/probe.args)

0 comments on commit 8f2ea9f

Please # to comment.