aboutsummaryrefslogtreecommitdiff
path: root/server/mkrepo
diff options
context:
space:
mode:
Diffstat (limited to 'server/mkrepo')
-rwxr-xr-xserver/mkrepo34
1 files changed, 27 insertions, 7 deletions
diff --git a/server/mkrepo b/server/mkrepo
index 119a81b..f89324e 100755
--- a/server/mkrepo
+++ b/server/mkrepo
@@ -3,14 +3,15 @@
# 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).
+# add it to the manifest file (used for mirroring), together with an optional
+# remote URL where the repository must additionally be mirrored to.
#
# --private
# make the repository private
#
# Note: <name> can be without the .git suffix.
#
-usage="usage: $0 [--private] <name>"
+usage="usage: $0 [--private] <name> [<remote-mirror-url>]"
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
@@ -41,22 +42,35 @@ if [ -z "$1" ]; then
fi
r="$1"
-if [ "$(basename "$1")" = "$(basename --suffix=.git "$1")" ]; then
+shift
+
+if [ "$(basename "$r")" = "$(basename --suffix=.git "$r")" ]; then
r="$r.git"
fi
+u=
+if [ -n "$1" ]; then
+ if [ "$public" = "n" ]; then
+ error "private repository cannot be mirrored"
+ fi
+
+ u="$1"
+fi
+
+gr='scm'
+
mkdir -p "$r"
-chgrp scm "$r"
+chgrp "$gr" "$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"
+chgrp -R "$gr" "$r"
if [ "$public" = "y" ]; then
f="$r/git-daemon-export-ok"
touch "$f"
- chgrp scm "$f"
+ chgrp "$gr" "$f"
chmod g+w "$f"
else
# Disable raw HTTP access to this directory.
@@ -67,5 +81,11 @@ fi
mv "$r/hooks/post-update.sample" "$r/hooks/post-update"
if [ "$public" = "y" ]; then
- echo "$r" >>manifest
+ l="$r"
+
+ if [ -n "$u" ]; then
+ l="$l $u"
+ fi
+
+ echo "$l" >>manifest
fi