X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=scripts%2Fgitcreate;h=3c7cd36a447b7bee5ab0ef0207e14b88dece1650;hb=6bf34e3c22fe68207b9e0561f3bd76e715d507c8;hp=45e1d051115f974c35276e5928ec1d751b25ef55;hpb=5d02d664162a4444581e276f89198e767fdc8d2c;p=repo_shell.git diff --git a/scripts/gitcreate b/scripts/gitcreate index 45e1d05..3c7cd36 100755 --- a/scripts/gitcreate +++ b/scripts/gitcreate @@ -1,31 +1,61 @@ #!/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 $([ -f /etc/repo_shell.conf ] && sed -e 's| ||g' < /etc/repo_shell.conf) +if [ -z "$owner" -o -z "$git_root" ]; then + echo "$0: please configure /etc/repo_shell.conf" + exit 1 fi +gitacls="$git_root/.gitacls" if [ "$(whoami)" != "$owner" ]; then echo "$0: must run as user $owner" >&2 exit 1 fi +unset yes +if [ "$1" = "-y" ]; then + yes=y + shift +fi + if [ $# -ne 1 ]; then echo "usage: $0 " >&2 exit 1 fi -if [ -e $git_root/$1 ]; then - echo "$0: repository $1 already exists" >&2 +repopath=$1 + +if [ -e $git_root/$repopath ]; then + echo "$0: repository $repopath already exists" >&2 + exit 1 +fi + +# Do not create subdirectories without asking first +repodir=$(dirname $repopath) +if [ ! -d "$git_root/$repodir" ]; then + if [ ! $yes ]; then + echo -n "Create git subdir '$repodir' (y/N)? " + read ans + ans=$(expr "$ans" : '\(.\).*') # works with dash too + if [ "$ans" != "y" -a "$ans" != "Y" ];then + echo "repository creation aborted at user request" + exit 0 + fi + fi + mkdir -p "$git_root/$repodir" 2>/dev/null + if [ ! -d "$git_root/$repodir" ]; then + echo "%0: repository not created, git subdir '$repodir' create failed" >&2 exit 1 + fi fi # Create the respository umask 027 -git --git-dir "$git_root/$1" init --bare +git --git-dir "$git_root/$repopath" 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