stagit

static git page generator
git clone https://git.awy.one/stagit
Log | Files | Refs | README | LICENSE

stagit-rebuild-all (907B) - View raw


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

REPO_BASE="/var/git/repos"
OUT_BASE="/var/www/htdocs/git"

echo "==> Starting stagit rebuild"
echo "    Repos: $REPO_BASE"
echo "    Output: $OUT_BASE"
echo

for repo in "$REPO_BASE"/*.git; do
	[ -e "$repo" ] || continue

	name=$(basename "$repo" .git)
	outdir="$OUT_BASE/$name"

	echo "==> Processing repo: $name"
	echo "    Source: $repo"
	echo "    Target: $outdir"

	if [ ! -d "$outdir" ]; then
		echo "    Creating directory: $outdir"
		if ! mkdir -p "$outdir"; then
			echo "    ERROR: failed to create $outdir" >&2
			exit 1
		fi
	fi

	echo "    Running stagit..."
	if (
		cd "$outdir" &&
		stagit "$repo" &&
		ln -sf log.html index.html
		ln -sf ../style.css style.css
		ln -sf ../logo.png logo.png
		ln -sf ../favicon.png favicon.png
		); then
		echo "    Done: $name"
	else
		echo "    ERROR: stagit failed for $name" >&2
		exit 1
	fi

	echo
done

echo "==> All repositories processed"