-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-indexes
executable file
·60 lines (45 loc) · 2.01 KB
/
build-indexes
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
53
54
55
56
57
58
59
60
#!/bin/bash
# The top-level script to read Master-Index and generate all the
# indexes/ files, including Master-Index.xml. It also updates the RSS
# feed.
# (Run this as root, please.)
# Note that this takes roughly 15 seconds to run, if the checksum cache
# (htdocs/checksum-cache.txt) already exists. Recreating the cache
# from scratch takes more like 150 seconds.
# (That's as of 2023. No doubt the times will creep up in future years.)
# Protect this script from running if it (or build-indexes) is already
# running. (It will fail if build.lock already exists.)
set -o noclobber
if { > /var/ifarchive/htdocs/build.lock ; } then
:
else
echo 'Build script is already running'
ls -l /var/ifarchive/htdocs/build.lock
exit
fi
set +o noclobber
# Build Master-Index.xml, all the index .html files, the metadata files,
# and the RSS feed file.
echo 'Rebuilding indexes...'
touch /var/ifarchive/htdocs/build.lasttime.tmp
/var/ifarchive/bin/ifmap.py --index /var/ifarchive/htdocs/if-archive/Master-Index --src /var/ifarchive/lib/ifmap --tree /var/ifarchive/htdocs --since /var/ifarchive/htdocs/build.lasttime
mv /var/ifarchive/htdocs/build.lasttime.tmp /var/ifarchive/htdocs/build.lasttime
# Make sure those files have the correct group and mode.
cd /var/ifarchive/htdocs/indexes
find . -type f -print0 | xargs -0 chmod 664
find . -type f -print0 | xargs -0 chgrp ifarchive
find . -type d -print0 | xargs -0 chmod 775
find . -type d -print0 | xargs -0 chgrp ifarchive
cd /var/ifarchive/htdocs/metadata
find . -type f -print0 | xargs -0 chmod 664
find . -type f -print0 | xargs -0 chgrp ifarchive
find . -type d -print0 | xargs -0 chmod 775
find . -type d -print0 | xargs -0 chgrp ifarchive
# Tell Unbox that Master-Index.xml has updated.
echo -n 'Unbox: '
unboxkey=$(sed -E -n 's/UnboxRefreshKey[[:space:]]*=[[:space:]]*([a-zA-Z0-9-]*)/\1/p' /var/ifarchive/lib/ifarch.config)
curl --silent --data "key=$unboxkey" "https://unbox.ifarchive.org/?recheck_index"
echo
echo 'Done.'
# Clean up the lock file.
rm /var/ifarchive/htdocs/build.lock