#! /usr/bin/env bash # Create remote git repository (on the server). You must run this script from # the "repositories root" (e.g., /var/scm) where you want the repository to be # created (including any subdirectories). If the repository is public, also # add it to the manifest file (used for mirroring). # # --private # make the repository private # # Note: is without the .git suffix. # usage="usage: $0 [--private] " owd="$(pwd)" trap "{ cd '$owd'; exit 1; }" ERR set -o errtrace # Trap in functions. function info () { echo "$*" 1>&2; } function error () { info "$*"; exit 1; } public="y" while [ "$#" -gt "0" ]; do case "$1" in --private) public="n" shift ;; -*) error "unknown option: $1" ;; *) break ;; esac done if [ -z "$1" ]; then error "repository name expected" fi r="$1" if [ "$(basename "$1")" = "$(basename --suffix=.git "$1")" ]; then r="$r.git" fi mkdir -p "$r" chgrp scm "$r" git --bare init --shared=all "$r" info "Enter project description (one line; or edit $r/descrition later)" info "Hit Ctrl-D when done" cat >"$r/description" chgrp -R scm "$r" if [ "$public" = "y" ]; then f="$r/git-daemon-export-ok" touch "$f" chgrp scm "$f" chmod g+w "$f" else # Disable raw HTTP access to this directory. # echo "deny from all" >"$r/.htaccess" fi mv "$r/hooks/post-update.sample" "$r/hooks/post-update" if [ "$public" = "y" ]; then echo "$r" >>manifest fi