rebuild-site.sh
1# forge-rebuild-site: rebuild kilimanjaro.io (/var/www/code) from every public,
2# non-hidden soft-serve repo, then the index. The post-receive hook runs it in
3# the background after each push; run it by hand after restoring
4# /var/soft/data (the site itself isn't backed up). Output goes to stdout; the
5# hook appends it to /var/log/pgit.log.
6
7# No session bus here: without this pgit/pgit-index autolaunch a dbus-daemon
8# per run that never exits (plan 2.3a).
9export DBUS_SESSION_BUS_ADDRESS=disabled:
10
11# hardcoded path to handle nested repos
12BASEDIR="/var/soft/data/repos"
13OUTDIR="/var/www/code"
14DBFILE="/var/soft/data/soft-serve.db"
15
16sqlite3 -noheader -list "$DBFILE" "SELECT name FROM repos WHERE private=0 AND hidden=0" |
17 while read -r value; do
18 IN="${BASEDIR}/${value}.git"
19 CLONE_URL="https://git.kilimanjaro.io/${value}"
20 HOME_URL="https://kilimanjaro.io/"
21 ROOT_RELATIVE="/${value}/"
22 OUT="${OUTDIR}/${value}"
23
24 if [ -f "$IN/description" ]; then
25 DESCRIPTION="$(cat "$IN/description")"
26 else
27 DESCRIPTION=""
28 fi
29
30 # clear out previous and overwrite
31 rm -rf "$OUT"
32 mkdir -p "$OUT"
33
34 pgit \
35 -q \
36 --repo "$IN" \
37 --out "$OUT" \
38 --root-relative "$ROOT_RELATIVE" \
39 --desc "$DESCRIPTION" \
40 --clone-url "$CLONE_URL" \
41 --home-url "$HOME_URL" \
42 --label "$value" \
43 --theme "github-dark" \
44 --revs "main" \
45 --issues 2>&1
46 echo "Built site for $value in $OUT"
47 done
48
49pgit-index --root "$OUTDIR" --order "rtw,rtw/editor,ygo,servers" 2>&1
50echo "Index built in $OUTDIR"