forked from ph00lt0/blocklist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.sh
executable file
·54 lines (43 loc) · 1.72 KB
/
delete.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
#!/bin/bash
echo "This is not for delisting domains, please use ./delist.sh"
read -p "Enter the mistake entry that you want to delete:" mistake
if [ "$mistake" == "" ]; then
echo "No mistake entry provided."
exit
fi
if [ "$mistake" == "v" ]; then
echo "Wrong paste command."
exit
fi
if [ "$mistake" == "[A[A" ]; then
echo "syntax error [A[A."
exit
fi
declare blocklist="./blocklist.txt"
declare piholeBlocklist="./pihole-blocklist.txt"
declare rpzBlocklist="./rpz-blocklist.txt"
declare unboundBlocklist="./unbound-blocklist.txt"
declare mistake=$(echo $mistake | sed -E 's/^\s*.*:\/\///g') # remove any https:// or http://.
declare mistake=$(echo $mistake | sed 's:/*$::') # remove any trailing slash.
declare author=$(git config user.name)
declare blocklistRule="||$mistake^"
declare piholeBlocklistRule="0.0.0.0 $mistake"
declare rpzBlocklistRule="$mistake CNAME ."
declare unboundBlocklistRule="local-zone: \"$mistake.\" always_null"
# Only check for default blocklist as pihole list should contain same domains.
if grep -q $blocklistRule "$blocklist"; then
echo "checking for updates..."
git pull origin master && git pull github master
if grep -q $blocklistRule "$blocklist"; then
sed -i '' "/$blocklistRule/d" $blocklist
sed -i '' "/$piholeBlocklistRule/d" $piholeBlocklist
sed -i '' "/$rpzBlocklistRule/d" $rpzBlocklist
sed -i '' "/$unboundBlocklistRule/d" $unboundBlocklist
python3 ./ls-delete.py $domain
git commit -am "Mea culpa, $author made a mistake: $mistake now removed from blocklist" && git push origin master && git push github master
else
echo "$domain rule corrected before you"
fi
else
echo "$domain mistake not present"
fi