MinimalistGit

Project to automate creating git repos on a minimal 'git daemon' server.
Log | Files | Refs | README | LICENSE

commit 3300f24d6eac9892f0e80347c7390160f0c58d24
parent f8b7e851b263434a8da88f4f0ca8d23f9aae547e
Author: Tyler Clark <tyler.clark@foxide.xyz>
Date:   Sun, 11 May 2025 22:02:29 -0400

Adding -r option for mkrepo script.

This commit adds an '-r' flag to enable creating repositories on remote systems
without interactively logging into them.

Diffstat:
Mscripts/mkrepo | 24+++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/scripts/mkrepo b/scripts/mkrepo @@ -13,6 +13,7 @@ REPODIR="/usr/local/www/git" TEMPLATE=0 PRIVATE=0 NO_DESC=0 +REMOTE="" help() { @@ -32,6 +33,22 @@ createRepo() EXT=.git fi + # The remote option uses SSH to automatically perform remote operations + # to avoid needing other orchestration tools + # The commands are essentially the same as doing the actions locally, + # they are just wrapped around SSH commands + if [ -n ${REMOTE} ]; then + ssh ${REMOTE} "git init --bare ${REPODIR}/${NAME}${EXT}" + ssh ${REMOTE} " + printf '#!/bin/sh\n + # This script is to generate the HTML for the git repo when a new commit is received\n + cd ${REPODIR}/${NAME}${EXT}\n + /usr/local/bin/stagit ./\n + /usr/local/bin/stagit-index ${REPODIR}/*git > ${REPODIR}/index.html' > ${REPODIR}/${NAME}${EXT}/hooks/post-receive" + ssh ${REMOTE} "chmod u+x ${REPODIR}/${NAME}${EXT}/hooks/post-receive" + exit 0 + fi + git init --bare ${REPODIR}/${NAME}${EXT} if [ ${NO_DESC} != 1]; then @@ -51,11 +68,12 @@ if [ "$#" -eq 0 ]; then help fi -while getopts ":Dhptn:" f; do +while getopts ":dhpr:tn:" f; do case $f in - D) NO_DESC=1;; + d) NO_DESC=1;; n) NAME=${OPTARG};; p) PRIVATE=1;; + r) REMOTE=${OPTARG};; t) TEMPLATE=1;; h | *) help exit @@ -64,4 +82,4 @@ while getopts ":Dhptn:" f; do done shift `expr $OPTIND - 1` -createRepo $NAME $PRIVATE $TEMPLATE +createRepo $NAME $REMOTE $PRIVATE $TEMPLATE