tech_notes

A collection of notes on setups and implementations.
Log | Files | Refs | README

commit de3e516e32678d7002e9369ebaefb30c5c1e22ef
parent 15121f6f81e44f899fd3f745eb666280ee1331a2
Author: Julian Piribauer <julian.piribauer@gmail.com>
Date:   Wed, 18 Feb 2026 20:41:18 +0100

Updating usage for public/private repos

Diffstat:
Mstagit.md | 55+++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/stagit.md b/stagit.md @@ -8,29 +8,55 @@ The web server has its root at /var/www/git/. ## Helper-script for executing stagit and stagit-index -First, we create a helper script: +First, we create a helper script that scans the repos/folders inside /srv/git/repos +and generates a website IF A FILE git-daemon-export-ok EXISTS. +Finally, all these public repos are listed in /var/www/git/index.html. /usr/local/bin/update-stagit.sh: #!/bin/sh - set -eu - REPO_PATH="$1" - REPO_NAME="$(basename "$REPO_PATH" .git)" + set -eu - HTML_ROOT="/var/www/git" - REPO_HTML="$HTML_ROOT/$REPO_NAME" REPO_ROOT="/srv/git/repos" + HTML_ROOT="/var/www/git" + + mkdir -p "$HTML_ROOT" + + INDEX_LIST="$(mktemp)" # creates some temporary file to list repos + + # For each repo with a git-daemon-export-ok file, we run stagit + for REPO_PATH in "$REPO_ROOT"/*.git; do + + REPO_NAME="$(basename "$REPO_PATH" .git)" + REPO_HTML="$HTML_ROOT/$REPO_NAME" + + if [ -f "$REPO_PATH/git-daemon-export-ok" ]; then + echo "Generating HTML for $REPO_NAME..." + mkdir -p "$REPO_HTML" + cd "$REPO_HTML" + stagit "$REPO_PATH" + echo "$REPO_PATH" >> "$INDEX_LIST" + + else + # Delete the folder if it was created earlier + rm -rf "$REPO_HTML" + fi - mkdir -p "$REPO_HTML" + done - # Generate repo pages - cd "$REPO_HTML" - stagit "$REPO_PATH" + # All such repos are then included in the index.html + if [ -s "$INDEX_LIST" ]; then + echo "Regenerating git index..." + cd "$HTML_ROOT" + stagit-index $(cat "$INDEX_LIST") > index.html + else + echo "No repos with git-daemon-export-ok file found" + rm -f "$HTML_ROOT/index.html" + fi - # Regenerate global index - cd "$HTML_ROOT" - stagit-index "$REPO_ROOT"/*.git > index.html + rm -f "$INDEX_LIST" + echo "done" and make it executable: chmod +x /usr/local/bin/update-git.sh @@ -42,7 +68,7 @@ We now set up a post-receive hook that creates the folder structure for new repo /srv/git/template/hooks/post-receive: #!/bin/sh - /usr/local/bin/update-stagit.sh "$(pwd)" + /usr/local/bin/update-stagit.sh Make it executable as well with chmod +. @@ -62,3 +88,4 @@ New repos can now be initiated on the server with git init --bare my_repo The website and the repo endpoint will be updated upon the first push. +Make sure to create a git-daemon-export-ok file to make the repo public.