forked from privacy-protection-tools/anti-AD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-ci.sh
executable file
·106 lines (86 loc) · 3.03 KB
/
start-ci.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
source /etc/profile
cd $(cd "$(dirname "$0")";pwd)
easylist=(
"https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt"
"https://easylist.to/easylist/fanboy-annoyance.txt"
"https://easylist.to/easylist/easyprivacy.txt"
"https://gitee.com/banbendalao/adguard/raw/master/ADgk.txt"
)
hosts=(
"https://raw.githubusercontent.com/neoFelhz/neohosts/gh-pages/full/hosts.txt"
"https://raw.githubusercontent.com/vokins/yhosts/master/hosts"
"https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts"
"https://www.malwaredomainlist.com/hostslist/hosts.txt"
)
strict_hosts=(
"https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt"
)
dead_hosts=(
"https://raw.githubusercontent.com/notracking/hosts-blocklists-scripts/master/domains.dead.txt"
"https://raw.githubusercontent.com/notracking/hosts-blocklists-scripts/master/hostnames.dead.txt"
)
rm -f ./origin-files/easylist*
rm -f ./origin-files/hosts*
rm -f ./origin-files/strict-hosts*
rm -f ./origin-files/dead-hosts*
for i in "${!easylist[@]}"
do
echo "开始下载 easylist${i}..."
curl -o "./origin-files/easylist${i}.txt" --connect-timeout 60 -s "${easylist[$i]}"
# shellcheck disable=SC2181
if [ $? -ne 0 ];then
echo '下载失败,请重试'
exit 1
fi
done
for i in "${!hosts[@]}"
do
echo "开始下载 hosts${i}..."
curl -o "./origin-files/hosts${i}.txt" --connect-timeout 60 -s "${hosts[$i]}"
# shellcheck disable=SC2181
if [ $? -ne 0 ];then
echo '下载失败,请重试'
exit 1
fi
done
for i in "${!strict_hosts[@]}"
do
echo "开始下载 strict-hosts${i}..."
curl -o "./origin-files/strict-hosts${i}.txt" --connect-timeout 60 -s "${strict_hosts[$i]}"
# shellcheck disable=SC2181
if [ $? -ne 0 ];then
echo '下载失败,请重试'
exit 1
fi
done
for i in "${!dead_hosts[@]}"
do
echo "开始下载 dead-hosts${i}..."
curl -o "./origin-files/dead-hosts${i}.txt" --connect-timeout 60 -s "${dead_hosts[$i]}"
# shellcheck disable=SC2181
if [ $? -ne 0 ];then
echo '下载失败,请重试'
exit 1
fi
done
cd origin-files
cat hosts*.txt | grep -v -E "^((#.*)|(\s*))$" \
| grep -v -E "^[0-9\.:]+\s+(ip6\-)?(localhost|loopback)$" \
| sed s/0.0.0.0/127.0.0.1/g | sed s/::/127.0.0.1/g | sort \
| uniq >base-src-hosts.txt
cat strict-hosts*.txt | grep -v -E "^((#.*)|(\s*))$" \
| grep -v -E "^[0-9\.:]+\s+(ip6\-)?(localhost|loopback)$" \
| sed s/0.0.0.0/127.0.0.1/g | sed s/::/127.0.0.1/g | sort \
| uniq >base-src-strict-hosts.txt
cat dead-hosts*.txt | grep -v -E "^(#|\!)" \
| sort \
| uniq >base-dead-hosts.txt
cat easylist*.txt | grep -E "^\|\|[^\*\^]+?\^" | sort | uniq >base-src-easylist.txt
cat easylist*.txt | grep -E "^\|\|?([^\^=\/:]+)?\*([^\^=\/:]+)?\^" | sort | uniq >wildcard-src-easylist.txt
cat easylist*.txt | grep -E "^@@\|\|?[^\^=\/:]+?\^([^\/=\*]+)?$" | sort | uniq >whiterule-src-easylist.txt
cd ../
php make-addr.php
echo
php ./tools/easylist-extend.php anti-ad-easylist.txt