From a6c6f0d2cfe2ffaa3995c52af97cdbdf9757ed43 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Mon, 22 Sep 2014 10:48:33 -0600 Subject: [PATCH] gitcreate: automatically re-run as repo owner If gitcreate as ran as root, it can restart itself using sudo so that it is ran as the correct repo owner user. This is a convenience change. --- scripts/gitcreate | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/gitcreate b/scripts/gitcreate index e1363c7..daa5eb4 100755 --- a/scripts/gitcreate +++ b/scripts/gitcreate @@ -11,6 +11,12 @@ gitaclspath="$git_root/$gitacls" githooks=.githooks githookspath="$git_root/$githooks" +# If running as root, rerun via sudo as user $owner to ensure proper permissions +if [ "$(whoami)" == "root" ]; then + sudo -u $owner $0 $* + exit $? +fi + if [ "$(whoami)" != "$owner" ]; then echo "$0: must run as user $owner" >&2 exit 1 -- 2.39.2