From 8aef14fdf5f32aefcc9b0091bdae3ae4a3d4d43e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 4 Jun 2018 18:51:58 +0300 Subject: Make mkrepo to optionally add mirror remote URL to manifest file --- server/mkrepo | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'server') 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: can be without the .git suffix. # -usage="usage: $0 [--private] " +usage="usage: $0 [--private] []" 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 -- cgit v1.1