mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-19 04:16:21 +00:00
Move all the flag parsing to main.go; implement scope help
This commit is contained in:
+9
-61
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "$0 --app.foo bar --probe.foo bar"
|
||||
@@ -6,89 +6,37 @@ usage() {
|
||||
}
|
||||
|
||||
mkdir -p /var/run/weave
|
||||
APP_ARGS=""
|
||||
PROBE_ARGS=""
|
||||
|
||||
TOKEN_PROVIDED=false
|
||||
|
||||
if [ "$1" = version ]; then
|
||||
/home/weave/scope version
|
||||
if [ "$1" = "version" -o "$1" = "help" ]; then
|
||||
exec -a scope /home/weave/scope --mode $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--app.*)
|
||||
if echo "$1" | grep "=" 1>/dev/null; then
|
||||
ARG_NAME=$(echo "$1" | sed 's/\-\-app\.\([^=]*\)=\(.*\)/\1/')
|
||||
ARG_VALUE=$(echo "$1" | sed 's/\-\-app\.\([^=]*\)=\(.*\)/\2/')
|
||||
else
|
||||
[ $# -gt 1 ] || usage
|
||||
ARG_NAME=$(echo "$1" | sed 's/\-\-app\.//')
|
||||
ARG_VALUE="$2"
|
||||
shift
|
||||
fi
|
||||
APP_ARGS="$APP_ARGS -$ARG_NAME=$ARG_VALUE"
|
||||
;;
|
||||
--debug)
|
||||
APP_ARGS="$APP_ARGS -log.level=debug"
|
||||
PROBE_ARGS="$PROBE_ARGS -log.level=debug"
|
||||
;;
|
||||
for arg in $@; do
|
||||
case "$arg" in
|
||||
--no-app|--probe-only)
|
||||
touch /etc/service/app/down
|
||||
;;
|
||||
--no-probe|--app-only)
|
||||
touch /etc/service/probe/down
|
||||
;;
|
||||
--weave.hostname*)
|
||||
if echo "$1" | grep "=" 1>/dev/null; then
|
||||
ARG_VALUE=$(echo "$1" | sed 's/\-\-weave.hostname=\(.*\)/\1/')
|
||||
else
|
||||
[ $# -gt 1 ] || usage
|
||||
ARG_VALUE="$2"
|
||||
shift
|
||||
fi
|
||||
PROBE_ARGS="$PROBE_ARGS -weave.hostname=$ARG_VALUE"
|
||||
APP_ARGS="$APP_ARGS -weave.hostname=$ARG_VALUE"
|
||||
;;
|
||||
--probe.*)
|
||||
if echo "$1" | grep "=" 1>/dev/null; then
|
||||
ARG_NAME=$(echo "$1" | sed 's/\-\-probe\.\([^=]*\)=\(.*\)/\1/')
|
||||
ARG_VALUE=$(echo "$1" | sed 's/\-\-probe\.\([^=]*\)=\(.*\)/\2/')
|
||||
else
|
||||
[ $# -gt 1 ] || usage
|
||||
ARG_NAME=$(echo "$1" | sed 's/\-\-probe\.//')
|
||||
ARG_VALUE="$2"
|
||||
shift
|
||||
fi
|
||||
PROBE_ARGS="$PROBE_ARGS -$ARG_NAME=$ARG_VALUE"
|
||||
;;
|
||||
--service-token*)
|
||||
if echo "$1" | grep "=" 1>/dev/null; then
|
||||
ARG_VALUE=$(echo "$1" | sed 's/\-\-service-token=\(.*\)/\1/')
|
||||
else
|
||||
[ $# -gt 1 ] || usage
|
||||
ARG_VALUE="$2"
|
||||
shift
|
||||
fi
|
||||
PROBE_ARGS="$PROBE_ARGS -token=$ARG_VALUE"
|
||||
TOKEN_PROVIDED=true
|
||||
touch /etc/service/app/down
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "$APP_ARGS" >/var/run/weave/scope-app.args
|
||||
echo "$PROBE_ARGS" >/var/run/weave/scope-probe.args
|
||||
echo "$@" >/var/run/weave/scope-app.args
|
||||
echo "$@" >/var/run/weave/scope-probe.args
|
||||
|
||||
# End of the command line can optionally be some
|
||||
# addresses of apps to connect to, for people not
|
||||
# using Weave DNS. We stick these in /var/run/weave/apps
|
||||
# for the run-probe script to pick up.
|
||||
MANUAL_APPS=$@
|
||||
MANUAL_APPS=""
|
||||
|
||||
# Implicitly target the Scope Service if a service token was provided with
|
||||
# no explicit manual app.
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec -a scope-app /home/weave/scope app $(cat /var/run/weave/scope-app.args)
|
||||
exec -a scope-app /home/weave/scope --mode app $(cat /var/run/weave/scope-app.args)
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec -a scope-probe /home/weave/scope probe $(cat /var/run/weave/scope-probe.args) $(cat /var/run/weave/apps)
|
||||
exec -a scope-probe /home/weave/scope --mode probe $(cat /var/run/weave/scope-probe.args) $(cat /var/run/weave/apps)
|
||||
|
||||
Reference in New Issue
Block a user