stagit

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

stagit-rebuild-all (965B) - 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
48
49
50
51
52
#!/bin/sh
# Author: awy
# License: MIT

. /home/git/config.rc

echo "==> Starting stagit rebuild"
echo "    Repos: $GIT_HOME"
echo "    Output: $WWW_HOME"
echo

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

	name=$(basename "$repo" .git)
	outdir="$WWW_HOME/$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" &&
    rm -rf "$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 "==> Updating index"
stagit-gen-index

echo "==> All repositories processed"