Some people use a hostname other than raspberrypi, so their hostname
did not resolve to 127.0.0.1. I replaced that hardcoded value with a
variable so that does not happen.
I also added a few comments and minor formatting adjustments,.
Detects if the Pi had an original Pi-hole by looking for adList.conf.
If it exists, it backs up all the files to /etc/pihole/original. Then,
the script continues as normal and creates the new files. This helps
ensure that /etc/hosts and /etc/dnsmasq.d/adList.conf are not being
used simultaneously.
You can add your own config file to permanently set variables used in
the gravity script. If the file exists, gravity.sh will detect it and
apply your custom variables. This is useful so when there is an update
to the gravity script, you do not need to adjust the variables every
time.
This script is for use with an Adafruit LCD so that you can peek at the
domains as they are blocked in real time. It's not necessary for the
Pi-hole to function, but something fun I am working on. There will be
a video in the next article I post.
Pushing files so they are available when the new article gets posted.
If the Pi's loopback is set in the hosts file, clients using it as a
DNS server will try to connect to their own loopback, which does not
have a Web server. So the real IP of the Pi is used. It is
recommended to use a static IP since this will be acting as a server.
Made one small change from some hard coded values to a variable.
Originally, I had this set to /run/shm (in RAM) but ran into errors
when the list reached 900,000 entries.
Then I moved it to /tmp.
Finally, I decided to just put the files in the pihole dir so they are
available after reboots. This will help with only downloading the
lists when absolutely needed--respecting the bandwidth of the people
serving the lists.
It is also possible to add addn-hosts=/path/to/hosts.conf within the
dnsmasq.conf file if you don't want to use hosts. For simplicity and
speed, I just use the regular hosts file.
Still need to get lighted to use IPv6. I am doing this because some
ads can get through using IPv6 if the IPv4 version is blocked. Also,
it seems to work fine as far as performance even though it doubles the
file size...
Also added a few comments for better documentation.
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.