#!/bin/sh yourname="Sebastiano Tronto" repo="$PWD" name="$(basename $repo .git)" baseurl="https://git.tronto.net" basedir="/var/www/htdocs/git.tronto.net" htdir="$basedir/$name" filesdir="/home/git/FILES" bindir="/home/git/BIN" setupinfo() { echo "$yourname" > owner echo "$baseurl/$name" > url git update-server-info } genstagit() { rm -rf "$htdir" mkdir -p "$basedir" cp -r "$repo" "$htdir" cd "$htdir" stagit -l 100 "$repo" git archive HEAD -o "$basedir/$name.zip" git show master:README.md > file/README.md } cpindexfile() { cp "$htdir/files.html" "$htdir/index.html" } cpstylefiles() { cp $filesdir/favicon.png "$1" cp $filesdir/logo.png "$1" cp $filesdir/style.css "$1" } formatreadme() { cd "$htdir" printf '%s\n' \ g/class=\"line\"/d \ "/
" d d i "$(lowdown file/README.md)" . w \
| ed -s file/README.md.html > /dev/null
}
adddownloadbutton() {
cd "$htdir"
printf '%s\n' \
"/log\.html\">Log<\/a>" i \
"Download |" . w \
| ed -s "$1" > /dev/null
}
addbottombar() {
printf '%s\n' \
"/<\/body>" i "$(cat $filesdir/bottom.html)" . w \
| ed -s "$1" > /dev/null
}
changeindextitlestyle() {
printf '%s\n' \
"/Repositories" c \
" Repositories
" . w \
| ed -s "$basedir/index.html" > /dev/null
}
genstagitindex() {
stagit-index /home/git/*.git | \
sed 's|/log\.html||g' > "$basedir/index.html"
}
mkpage() {
echo "Updating stagit page for $name"
setupinfo
genstagit
cpindexfile
cpstylefiles "./"
[ -e $htdir/file/README.md ] && formatreadme
for f in $(find "$htdir" -name "*.html"); do
adddownloadbutton $f
addbottombar $f
done
mkindex
}
mkindex() {
echo "Updating stagit index page"
genstagitindex
cpstylefiles "$basedir/"
addbottombar "$basedir/index.html"
changeindextitlestyle
}
if [ "$1" = "all" ]; then
for g in *.git; do
cd $g
cp $bindir/post-receive-stagit hooks/post-receive
chmod +x hooks/post-receive
$bindir/post-receive-stagit
cd
done
elif [ "$1" = "index" ]; then
mkindex
else
mkpage
fi