3
3
# (c) 2016 by TBDS
4
4
# https://github.com/tbds/FreeContributor
5
5
#
6
+ # FreeContributor is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
6
10
# Simple script that pulls ad blocking host files from different providers
7
11
# and combines them to use as a dnsmasq resolver file.
8
12
#
13
+ #
9
14
# A, --address=/<domain>/ [domain/] <ipaddr>
10
15
# Specify an IP address to return for any host in the given
11
16
# domains. Queries in the domains are never forwarded and always
21
26
# or DHCP and not sent to an upstream nameserver by a more spe-
22
27
# cific --server directive."
23
28
#
24
- # FreeContributor is free software: you can redistribute it and/or modify
25
- # it under the terms of the GNU General Public License as published by
26
- # the Free Software Foundation, either version 3 of the License, or
27
- # (at your option) any later version.
28
-
29
+ #
30
+ #
29
31
# Dependencies:
30
32
# * curl
31
33
# * dnsmasq
32
34
# * GNU coreutils
33
35
34
- # Declair variables
35
- resolv=/etc/resolv.conf
36
+ # variables
37
+ resolvconf=/etc/resolv.conf
38
+ resolvconfbak=/etc/resolv.conf.bak
36
39
dnsmasqdir=/etc/dnsmasq.d
37
40
dnsmasqconf=/etc/dnsmasq.conf
38
41
dnsmasqconfbak=/etc/dnsmasq.conf.bak
@@ -55,28 +58,38 @@ echo "
55
58
"
56
59
}
57
60
61
+
58
62
rootcheck (){
59
63
if [[ $UID -ne 0 ]]; then
60
- echo " Please run this script as root"
64
+ echo " You need root or su rights to access /etc directory"
65
+ echo " Please run this script as root (like a boss)"
61
66
exit 1
62
67
fi
63
68
}
64
69
65
70
dependencies (){
66
- programs=( wget curl sed unzip 7z dnsmasq )
71
+ programs=( wget curl sed dnsmasq ) # unzip 7z
67
72
for prg in " ${programs[@]} "
68
73
do
69
74
type -P $prg & > /dev/null || { echo " Error: FreeConributor requires the program $prg ... Aborting." ; echo ; exit 192; }
70
75
done
71
76
}
72
77
73
78
backup (){
74
- if [ ! -f " $dnsmasqconf " ] ; then
75
- echo " Backing up your previous dnsmasq file"
79
+ if [ ! -f " $resolvconf " ] && [ ! -f " $dnsmasqconf " ]; then
80
+ echo " Backing up your previous resolv and dnsmasq file"
81
+ sudo cp $resolvconf $resolvconfbak
76
82
sudo cp $dnsmasqconf $dnsmasqconfbak
77
83
fi
78
84
}
79
85
86
+ config (){
87
+ if [ ! -d " $dnsmasqdir " ]; then
88
+ mkdir -p " $dnsmasqdir "
89
+ fi
90
+ }
91
+
92
+
80
93
download_sources (){
81
94
# # See FilterLists for a comprehensive list of filter lists from all over the web
82
95
# # https://filterlists.com/
@@ -88,15 +101,18 @@ sources=(\
88
101
' http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext' \
89
102
' http://someonewhocares.org/hosts/hosts' \
90
103
' http://sysctl.org/cameleon/hosts' \
91
- ' http://securemecca.com/Downloads/hosts.txt' \
92
- ' https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts' \
93
- # 'https://hosts.neocities.org/' \
104
+ ' http://securemecca.com/Downloads/hosts.txt
105
+ ' https://raw.githubusercontent.com/gorhill/uMatrix/master/assets/umatrix/blacklist.txt' \
94
106
' http://www.malwaredomainlist.com/hostslist/hosts.txt' \
95
107
' http://malwaredomains.lehigh.edu/files/justdomains' \
108
+ ' http://www.joewein.net/dl/bl/dom-bl.txt' \
96
109
' http://adblock.gjtech.net/? format=hostfile' \
110
+ ' https://zeustracker.abuse.ch/blocklist.php? download=domainblocklist' \
111
+ ' http://adblock.mahakala.is/' \
97
112
' https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt'
113
+
114
+ # ' https://hosts.neocities.org/' \
98
115
# ' https://publicsuffix.org/list/effective_tld_names.dat' \
99
- # 'http://jansal.googlecode.com/svn/trunk/adblock/hosts' \
100
116
# ' http://malwaredomains.lehigh.edu/files/justdomains' \
101
117
# ' http://cdn.files.trjlive.com/hosts/hosts-v8.txt' \
102
118
# ' https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt' \
@@ -108,7 +124,6 @@ sources=(\
108
124
# ' https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt' \
109
125
# ' http://spam404bl.com/spam404scamlist.txt' \
110
126
# ' http://malwaredomains.lehigh.edu/files/domains.txt' \
111
- # 'http://www.joewein.net/dl/bl/dom-bl.txt' \
112
127
# ' http://www.sa-blacklist.stearns.org/sa-blacklist/sa-blacklist.current' \
113
128
# ' https://easylist-downloads.adblockplus.org/malwaredomains_full.txt' \
114
129
# ' https://easylist-downloads.adblockplus.org/easyprivacy.txt' \
@@ -155,17 +170,39 @@ dnsmasq-conf(){
155
170
echo domains dnsmasq-domains.conf; wc -l dnsmasq-domains.conf
156
171
}
157
172
173
+
158
174
finish (){
175
+ mv domains-extracted /etc/dnsmaq.d/dnsmasq-block.conf
176
+ rm tmp
159
177
echo " Done"
160
178
}
161
179
180
+ start-deamons (){
181
+ # https://github.com/DisplayLink/evdi/issues/11#issuecomment-193877839
182
+
183
+ INIT= ` ls -l /proc/1/exe`
184
+ if [[ $INIT == * " systemd" * ]]; then
185
+ systemctl enable dnsmasq.service && systemctl start dnsmasq.service
186
+ elif [[ $INIT == * " upstart" * ]]; then
187
+ service dnsmasq start
188
+ elif [[ $INIT == * " /sbin/init" * ]]; then
189
+ INIT=` /sbin/init --version`
190
+ if [[ $INIT == * " systemd" * ]]; then
191
+ systemctl enable dnsmasq.service && systemctl start dnsmasq.service
192
+ elif [[ $INIT == * " upstart" * ]]; then
193
+ service dnsmasq start
194
+ fi
195
+ fi
196
+ }
162
197
163
198
164
199
# welcome
165
200
# rootcheck
166
201
# dependencies
167
202
# backup
203
+ # config
168
204
download_sources
169
205
extract_domains
170
206
dnsmasq-conf
171
- finish
207
+ finish
208
+ # start-deamons
0 commit comments