-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall_filter.sh
33 lines (29 loc) · 1.08 KB
/
install_filter.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
#! /bin/bash
# Some variables
readonly INSTALL_DIR="/etc/trivalent/filter"
readonly OLD_DIR="$HOME/.config/chromium"
readonly FILTER_VER="$(cat $INSTALL_DIR/trivalent-blocklist-version.txt)"
readonly CURRENT_VER="$(ls $OLD_DIR/Subresource\ Filter/Unindexed\ Rules)"
echo "Checking version" # Debug statement
echo " Installed version: $CURRENT_VER" # Debug statement
echo " Package version: $FILTER_VER" # Debug statement
if [ "$FILTER_VER" == "$CURRENT_VER" ]; then
echo "No need to update, versions match" # Debug statement
exit 0
fi
readonly NEW_DIR="$OLD_DIR/Subresource Filter/Unindexed Rules/$FILTER_VER"
echo "Removing '$OLD_DIR/Subresource Filter'" # Debug statement
rm -r "$OLD_DIR/Subresource Filter"
echo "Creating '$NEW_DIR'" # Debug statement
mkdir -p "$NEW_DIR"
echo "Adding filter list from '$INSTALL_DIR'" # Debug statement
cp "$INSTALL_DIR/trivalent-blocklist" "$NEW_DIR/Filtering Rules"
echo "Creating 'manifest.json'"
cat << EOF > "$NEW_DIR/manifest.json"
{
"manifest_version": 2,
"name": "Subresource Filtering Rules",
"ruleset_format": 1,
"version": "$FILTER_VER"
}
EOF