aboutsummaryrefslogtreecommitdiff
path: root/server/mkrepo
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-04 18:51:58 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-04 21:04:49 +0300
commit8aef14fdf5f32aefcc9b0091bdae3ae4a3d4d43e (patch)
treee97acc7cabede5334b91f881713982584685893e /server/mkrepo
parent05af074f7d6f66ce400241e869e623eb72b85c01 (diff)
Make mkrepo to optionally add mirror remote URL to manifest file
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