diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-18 18:01:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-18 18:01:13 +0200 |
commit | f697b300cc0b421b196193c090df54a121b1d398 (patch) | |
tree | a9fe24da2f1a4fec4f6d6df50cc46a1c60d316b1 /server/mkrepo | |
parent | c74e6e00cf4125731e6f9d6a5472989be1c6d1d0 (diff) |
Add script for mirroring, update creation script to support
Diffstat (limited to 'server/mkrepo')
-rwxr-xr-x | server/mkrepo | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/server/mkrepo b/server/mkrepo new file mode 100755 index 0000000..f372d2e --- /dev/null +++ b/server/mkrepo @@ -0,0 +1,73 @@ +#! /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. If the repository is public, also add it to the manifest file (used +# for mirroring). +# +# Usage: mkrepo [<options>] <name> +# +# --private +# make the repository private +# +# Note: <name> is without the .git suffix. +# +trap 'exit 1' ERR + +function error () +{ + echo "$*" 1>&2 +} + +public=y + +while [ $# -gt 0 ]; do + case $1 in + --private) + public=n + shift + ;; + -*) + error "unknown option: $1" + exit 1 + ;; + *) + break + ;; + esac +done + +if [ "$1" = "" ]; then + error "repository name expected" + exit 1 +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 +error "Enter project description (one line; or edit $r/descrition later)" +error "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 |