From: R. Steve McKown Date: Mon, 22 Sep 2014 16:48:33 +0000 (-0600) Subject: gitcreate: automatically re-run as repo owner X-Git-Tag: 0.9~3 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=repo_shell.git;a=commitdiff_plain;h=a6c6f0d2cfe2ffaa3995c52af97cdbdf9757ed43 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. --- 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