]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - scripts/gitcreate
gitcreate creates subdirs after asking user
[repo_shell.git] / scripts / gitcreate
index 45e1d051115f974c35276e5928ec1d751b25ef55..7a46d1b0ab6e0b62652339e9ba4fc6da27e46dea 100755 (executable)
@@ -1,10 +1,11 @@
 #!/bin/sh
 # gitcreate is part of the repo_shell distribution.
 
-eval $(sed -e 's| ||g' < /etc/repo_shell.cfg)
-if [ -z "$owner" -o -z "$git_root" -o -z "$git_acl_file" ]; then
-    echo "$0: please configure /etc/repo_shell.cfg"
+eval $(sed -e 's| ||g' < /etc/repo_shell.conf)
+if [ -z "$owner" -o -z "$git_root" ]; then
+    echo "$0: please configure /etc/repo_shell.conf"
 fi
+gitacls="$git_root/.gitacls"
 
 if [ "$(whoami)" != "$owner" ]; then
     echo "$0: must run as user $owner" >&2
@@ -21,11 +22,30 @@ if [ -e $git_root/$1 ]; then
     exit 1
 fi
 
+# Do not create subdirectories without asking first
+repopath=$(dirname $1)
+if [ ! -d "$git_root/$repopath" ]; then
+  echo -n "Create git subdir '$repopath' (y/N)? "
+  read ans
+  if [ "$ans" = "y" -o "$ans" = "Y" -o "$ans" = "yes" -o "$ans" = "Yes" \
+      -o "$ans" = "YES" ];then
+    mkdir -p "$git_root/$repopath" 2>/dev/null
+    if [ ! -d "$git_root/$repopath" ]; then
+      echo "%0: repository not created, git subdir '$repopath' create failed" >&2
+      exit 1
+    fi
+  else
+    echo "repository creation aborted at user request"
+    exit 0
+  fi
+fi
+
 # Create the respository
 umask 027
 git --git-dir "$git_root/$1" init --bare
 [ $? -ne 0 ] && exit 1
 
-echo "Repository created.
-Be sure to edit $git_acl_file to allow user access, if needed."
+[ -f "$gitacls" ] && echo "Check $gitacls for proper access permissions"
+echo "Repository created."
+[ ! -f "$gitacls" ] && echo "WARNING: $gitacls DOES NOT EXIST!"
 exit 0