X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=repo-gen.sh;h=d3440483e8bf5775d3aa23c018d82c7a8e85aab5;hb=90a85134ce69eb5470a8248ebe7bdadc588e5d1e;hp=f74e02f0b416ef2e41a7b024ca9e698eb53c2d01;hpb=c4f46c3f9ccded868ccc32b2aaac89cf40d9b196;p=stagit.git diff --git a/repo-gen.sh b/repo-gen.sh index f74e02f..d344048 100755 --- a/repo-gen.sh +++ b/repo-gen.sh @@ -1,33 +1,60 @@ #!/bin/sh fresh=false +unique=false for arg in "$@"; do + [ "$unique" = true ] && unique="$arg" + [ "$arg" = "--only" ] && unique=true [ "$arg" = "--fresh" ] && fresh=true done -STAGIT=/var/www/git/stagit +[ "$unique" = true ] && { + echo "Expected argument after \`--only\`."; + exit 1; +} + +STAGIT=/var/www/git/stagit.out [ ! -f "$STAGIT" ] && STAGIT=stagit -STAGIT_INDEX=/var/www/git/stagit-index +STAGIT_INDEX=/var/www/git/stagit-index.out [ ! -f "$STAGIT_INDEX" ] && STAGIT_INDEX=stagit-index -for repo in /srv/git/*.git; do - repo="$(basename "$repo" | cut -f 1 -d '.')" +build_html () { + repo="$1" + repo="$(basename "$repo" | sed 's/\.git$//g')" - [ "$fresh" = true ] \ - && echo "Deleting HTML for $repo." \ - && rm -fr "/var/www/git/$repo" + [ "$fresh" = true ] && { + echo "Deleting HTML for $repo."; + rm -fr "/var/www/git/$repo"; + } mkdir -p "/var/www/git/$repo" - cd "/var/www/git/$repo" + cd "/var/www/git/$repo" || { echo "Couldn't cd."; exit 1; } [ ! -f style.css ] && ln -s ../style.css ./ [ ! -f favicon.png ] && ln -s ../favicon.png ./ [ ! -f logo.png ] && ln -s ../logo.png ./ + [ ! -f highlight ] && ln -s ../highlight ./ echo "git://git.knutsen.co/$repo" > "/srv/git/$repo.git/url" - "$STAGIT" "/srv/git/$repo.git" -done - + COMMAND="$STAGIT /srv/git/$repo.git" + echo "Building web-page for $repo." + echo "$COMMAND" + $COMMAND +} + +if [ "$unique" = false ]; then + for repo in /srv/git/*.git; do + build_html "$repo" + done +else + build_html "$unique" +fi + +echo "Generating index.html with \`$STAGIT_INDEX\`." "$STAGIT_INDEX" /srv/git/*.git > /var/www/git/index.html + +# Correct ownership of the web files. +chown git:www-data -R /var/www/git -f +chmod g+rw -R /var/www/git -f