-
Notifications
You must be signed in to change notification settings - Fork 130
/
generate.sh
78 lines (56 loc) · 1.98 KB
/
generate.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
set -euo pipefail
echo "::group::Init"
log () {
echo `date +"%m/%d/%Y %H:%M:%S"` "$@"
}
cleanup() {
rm -f filtrite >> /dev/null 2>&1
}
cleanup
# Make sure all dependencies are installed
sudo apt-get install -y unzip wget || true
echo "::endgroup::"
echo "::group::Build executable"
log "Building"
go build -v -o filtrite
echo "::endgroup::"
echo "::group::Downloading latest ruleset_converter build"
install_bromite_ruleset_converter() {
log "Downloading from latest Bromite release"
rm -rf deps || true
mkdir -p deps
wget -O "deps/ruleset_converter" "https://github.com/bromite/bromite/releases/latest/download/ruleset_converter"
}
install_selfbuilt_ruleset_converter() {
log "Downloading from latest self-built release"
rm -rf deps || true
mkdir -p deps
wget -O "subresource_filter_tools_linux.zip" "https://github.com/xarantolus/subresource_filter_tools/releases/latest/download/subresource_filter_tools_linux-x64.zip"
unzip -ou "subresource_filter_tools_linux.zip" -d deps
rm "subresource_filter_tools_linux.zip"
}
# Use more up to date first, but if that fails, fall back to old bromite tool
install_selfbuilt_ruleset_converter || install_bromite_ruleset_converter
echo "::endgroup::"
echo "::group::Other setup steps"
chmod +x filtrite
chmod +x deps/ruleset_converter
mkdir -p dist
mkdir -p logs
echo "::endgroup::"
# If the default list file exists, we overwrite it with the actual official list
if [[ -f "lists/bromite-default.txt" ]]; then
echo "::group::Downloading official list"
wget -O "lists/bromite-default.txt" "https://raw.githubusercontent.com/bromite/filters/master/lists.txt"
echo "::endgroup::"
fi
# Now that everything is set up, we can start actually generating filter lists
./filtrite
echo "::group::Cleanup"
cleanup
# Reset the downloaded list to the previous text, in case this is run locally
if [[ -f "lists/bromite-default.txt" ]]; then
git restore lists/bromite-default.txt
fi
echo "::endgroup::"