From 7752d6b102d906965659ccb347b7d91a756eb8ae Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 19 Apr 2015 13:18:22 +0100 Subject: [PATCH] refactor: move "need to run as root" check to a more obvious place --- weave | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/weave b/weave index 9d6bb1f4..92388f2a 100755 --- a/weave +++ b/weave @@ -73,10 +73,6 @@ exec_remote() { if [ "$1" = "--local" ]; then LOCAL="$1" shift 1 - [ $(id -u) = 0 ] || { - echo "weave must be run as 'root' when run locally" >&2 - exit 1 - } elif [ "$1" != "run" ]; then exec_remote "$@" exit $? @@ -564,6 +560,11 @@ populate_dns() { ########################################################################################## if [ -n "$LOCAL" ]; then + [ $(id -u) = 0 ] || { + echo "weave must be run as 'root' when run locally" >&2 + exit 1 + } + uname -s -r | sed -n -e 's|^\([^ ]*\) \([0-9][0-9]*\)\.\([0-9][0-9]*\).*|\1 \2 \3|p' | { if ! read sys maj min ; then echo "ERROR: Unable to parse operating system version $(uname -s -r)" >&2