1
|
#!/bin/sh
|
2
|
|
3
|
if [ 0 != $(id -u) ]; then
|
4
|
echo must be root >&2
|
5
|
exit 1
|
6
|
fi
|
7
|
|
8
|
HYDRILLA_DIR=/var/lib/hydrilla
|
9
|
CONTENT_DIR=$HYDRILLA_DIR/content
|
10
|
GORILLA="gorilla.py $CONTENT_DIR"
|
11
|
GENERATED_DIR=$HYDRILLA_DIR/json_export
|
12
|
INDEX_JSONS="$(find $HYDRILLA_DIR/content -name "index.json")"
|
13
|
GAWK_EXTRACTOR='match($0, /"pattern"\s*:\s*"([^"]+)"/, a) {print a[1]}'
|
14
|
AVAILABLE_PATTERNS="$(gawk "$GAWK_EXTRACTOR" $INDEX_JSONS)"
|
15
|
|
16
|
rm -rf $GENERATED_DIR
|
17
|
mkdir $GENERATED_DIR
|
18
|
|
19
|
cat > $GENERATED_DIR/index.html <<EOF
|
20
|
<!DOCTYPE html>
|
21
|
<html>
|
22
|
<head>
|
23
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
24
|
<meta http-equiv="Content-Security-Policy" content="script-src 'none'">
|
25
|
</head>
|
26
|
<body style="color: #555;">
|
27
|
<h3>Site fixes for use with <a href="https://hachettebugs.koszko.org/projects/hachette/wiki">Hachette</a></h3>
|
28
|
All-in-one <a href="./bundle.json">bundle</a>.
|
29
|
|
30
|
<h4>Fixes for particular URL patterns</h4>
|
31
|
Please note a fix for certain site might be split into multiple imprtable files, e.g. https://odysee.com and https://odysee.com/***.
|
32
|
<ul>
|
33
|
EOF
|
34
|
|
35
|
for PATTERN in $AVAILABLE_PATTERNS; do
|
36
|
PATTERN_FILENAME=$(echo "$PATTERN" | tr '/*' _).json
|
37
|
PATTERN_LINK="$(echo "$PATTERN" | sed 's_<_\<_g; s_>_\>_g')"
|
38
|
$GORILLA "$PATTERN" > $GENERATED_DIR/$PATTERN_FILENAME
|
39
|
echo " <li><a href=\"./$PATTERN_FILENAME\">$PATTERN_LINK</a></li>" \
|
40
|
>> $GENERATED_DIR/index.html
|
41
|
done
|
42
|
|
43
|
$GORILLA '*' > $GENERATED_DIR/bundle.json
|
44
|
|
45
|
cat >> $GENERATED_DIR/index.html <<EOF
|
46
|
</ul>
|
47
|
</body>
|
48
|
</html>
|
49
|
EOF
|