tech_notes

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

commit 095c1f974ff0b0cb10df92dae9aaae526d5bd33e
parent 94cbf30138bf6aad87ca97578c9cebd64c47b26e
Author: Julian Piribauer <julian.piribauer@gmail.com>
Date:   Wed, 18 Feb 2026 22:07:46 +0100

Adding bash style

Diffstat:
Mstagit.md | 97++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 49 insertions(+), 48 deletions(-)

diff --git a/stagit.md b/stagit.md @@ -13,57 +13,57 @@ Finally, all these public repos are listed in /var/www/git/index.html. Create /usr/local/bin/update-stagit.sh with - ```bash - #!/bin/bash - - set -eu - - REPO_ROOT="/srv/git/repos" - HTML_ROOT="/var/www/git" +```bash +#!/bin/bash - mkdir -p "$HTML_ROOT" +set -eu - INDEX_LIST="$(mktemp)" # creates some temporary file to list repos +REPO_ROOT="/srv/git/repos" +HTML_ROOT="/var/www/git" - # For each repo with a git-daemon-export-ok file, we run stagit - for REPO_PATH in "$REPO_ROOT"/*.git; do +mkdir -p "$HTML_ROOT" - REPO_NAME="$(basename "$REPO_PATH" .git)" - REPO_HTML="$HTML_ROOT/$REPO_NAME" +INDEX_LIST="$(mktemp)" # creates some temporary file to list repos - 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" +# For each repo with a git-daemon-export-ok file, we run stagit +for REPO_PATH in "$REPO_ROOT"/*.git; do - else - # Delete the folder if it was created earlier - rm -rf "$REPO_HTML" - fi + REPO_NAME="$(basename "$REPO_PATH" .git)" + REPO_HTML="$HTML_ROOT/$REPO_NAME" - done + 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" - # 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" + # Delete the folder if it was created earlier + rm -rf "$REPO_HTML" fi - rm -f "$INDEX_LIST" - echo "done" - ``` +done + +# 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 + +rm -f "$INDEX_LIST" +echo "done" +``` and make it executable: - ```bash - chmod +x /usr/local/bin/update-git.sh - ``` +```bash +chmod +x /usr/local/bin/update-git.sh +``` ## Post-receive hook @@ -71,10 +71,10 @@ We now set up a post-receive hook that creates the folder structure for new repo Inside /srv/git/template/hooks/post-receive: - ```bash - #!/bin/bash - /usr/local/bin/update-stagit.sh - ``` +```bash +#!/bin/bash +/usr/local/bin/update-stagit.sh +``` Make it executable as well with chmod +. @@ -82,15 +82,16 @@ Make it executable as well with chmod +. Instruct git to use it as a template: - ```bash - git config --system init.templateDir /srv/git/template - ``` +```bash +git config --system init.templateDir /srv/git/template +``` Finally, we give all users reading rights to all subfolders of the repo folders: - ```bash - chmod -R a+rX /srv/git/repos - chmod -R a+rX /var/www/git - ``` + +```bash +chmod -R a+rX /srv/git/repos +chmod -R a+rX /var/www/git +``` ## Usage