12-generate-ublock-origin-filter 727 Bytes
Newer Older
1
2
3
4
#!/bin/sh

set -e

spriver's avatar
spriver committed
5
6
echo "Installing sqlite3 for uBlock patterns+settings file conversion"

spriver's avatar
spriver committed
7
apt-get install --yes sqlite3
8
9
10

echo "Converting uBlock database dump into sqlite blob"

11
12
DUMP="/usr/share/tails/ublock-origin/ublock0.dump"
DATABASE="/etc/tor-browser/profile/extension-data/ublock0.sqlite"
13

14
mkdir -p "$(dirname "${DATABASE}")"
15

16
17
18
19
20
# The sed expression simply means: remove all CRLF ("\r\n"). The use
# of labels is simply to make this able to remove multiple CRLF to
# create a single (long) line. In the end, this restores the
# diff-friendly dump to the original sqlite dump.
sed ':a;N;$!ba;s_\r\n__g' "${DUMP}" | sqlite3 "${DATABASE}"
21
22
23
24

echo "Created uBlock sqlite blob successfully"

apt-get purge --remove --yes sqlite3