What's new:
- whitelist and blacklist bug fix
- subdomains of items in whitelist are whitelisted too
- subdomains of items in blacklist are blacklisted too
- comments (lines starting with #) and blank lines are allowed in whitelist and in blacklist
- definition of variables at the beginning of the code
- smarter algorithm that reduces the number of entries in dnsmaq configuration file (i.e. if adsite.com is blocked there is no need to block www.adsite.com ad1.adsite.com whatever.adsite.com etc.) this reduce the number of entries in the output from ~ 140k down to ~ 92k.
- domain list is sorted in reverse (right to left) order: TLD first, then domain name and subdomains at the end.
This fixes#6 by changing the location of the whitelist.txt file.
Instead of storing it in the current users home folder, it should be
created in /etc/pihole. The script will also create the directory if
it does not exist, but will not add a whitelist.txt by default. You
would still need to go back and manually add one. But this directory
will be used to store other support files as the script improves.
I also added sudo commands to the commands requiring elevation.
Finally, changed the comment to reflect a more accurate number of
domains getting blocked.
Just put a file named whitelist.txt in your home folder. This file
should contain one domain per line that needs to be whitelisted. If
the file does not exists, the script will continue as normal.
http://jacobsalmela.com/raspberry-pi-ad-blocker-advanced-setup/#comment-
1860675175
Thanks to napgravy for figuring this out. It seems the DOS-style
line-endings that prevented uniq from getting rid of them. This
reduces the ad domains from ~140,000 to around ~120,000 but it is much
more accurate.
In addition to the extra domains, there are numerous performance
improvements so the script runs faster. There were also some
extraneous domains that were either blank or had some special
characters that needed to be removed.
Since the ad lists are not under my control, the end of the script will
now tell you how many domains will be blocked. In case the sources it
pulls from ever update, you can run this script again and see the
difference.