]> oss.titaniummirror.com Git - repo_shell.git/commitdiff
gitcreate: automatically re-run as repo owner
authorR. Steve McKown <rsmckown@gmail.com>
Mon, 22 Sep 2014 16:48:33 +0000 (10:48 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Mon, 22 Sep 2014 16:48:33 +0000 (10:48 -0600)
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

index e1363c76aca93c69cfff539b074ad4e9101ba7b0..daa5eb4bd806b7aa0aebf50118ca9a7faa1cd858 100755 (executable)
@@ -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