newrepo (1077B)
1 #!/bin/sh 2 3 server="ENTER-YOUR-SSH-SERVER-INFO" 4 pubrepodir="ENTER-YOUR-GIT-DIRECTORY" 5 bindir="ENTER-STAGIT-BIN-DIRECTORY" 6 branch="ENTER-DEFAULT-BRANCH-NAME" 7 8 hook="$bindir/post-receive-stagit" 9 [ -f "$hook" ] || { echo "Missing $hook" >&2; exit 1; } 10 cd "$pubrepodir" || { echo "Cannot cd to $pubrepodir" >&2; exit 1; } 11 12 printf "Enter repository name (without .git): " 13 read -r reponame 14 reponame="${reponame%.git}" 15 16 case "$reponame" in 17 ""|*[!A-Za-z0-9._-]*|.*) 18 echo "Use only letters, digits, . _ - (not starting with a dot)." >&2 19 exit 1 ;; 20 esac 21 22 repo="$pubrepodir/$reponame.git" 23 [ -e "$repo" ] && { echo "$reponame.git already exists." >&2; exit 1; } 24 25 printf "Enter short description: " 26 read -r shrtdesc 27 28 git init --bare -b "$branch" "$repo" || exit 1 29 echo "$shrtdesc" > "$repo/description" 30 cp "$hook" "$repo/hooks/post-receive" 31 chmod +x "$repo/hooks/post-receive" 32 33 echo 34 echo "Created $reponame.git. Stagit git hook installed; the website updates on first push." 35 echo "From your PC: git remote add origin ssh://$server$repo" 36 echo " git push -u origin $branch"