Compare commits
363 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
01e1e34874 | ||
|
28a3cbfa87 | ||
|
0b480c2d3f | ||
|
391dea445a | ||
|
e074c72130 | ||
|
96f3f863e5 | ||
|
3877f6fd94 | ||
|
cbbc6df05a | ||
|
32ff7fb321 | ||
|
5537e57eec | ||
|
9c94af04cc | ||
|
3f0b15902d | ||
|
4d3835dde2 | ||
|
8514f42d0d | ||
|
6d9fbe8d41 | ||
|
849185d3c9 | ||
|
47cc757ed0 | ||
|
f6edd435af | ||
|
0c0dd914f7 | ||
|
c6405bc93b | ||
|
cdffdfbded | ||
|
0bbfb323b1 | ||
|
4f08359786 | ||
|
7efb17537a | ||
|
7e06769d44 | ||
|
5347ee4896 | ||
|
834bf30a10 | ||
|
22ea384ac8 | ||
|
3e6dd9ea9e | ||
|
10f363e9e7 | ||
|
69e8c014c3 | ||
|
dbb40e1dda | ||
|
d710b97276 | ||
|
0e6e8040ba | ||
|
c6fb0bad4b | ||
|
2d08217173 | ||
|
36645d9335 | ||
|
97d3aedba1 | ||
|
5976b20aec | ||
|
ad8573c739 | ||
|
7f9410fd34 | ||
|
71133f6b59 | ||
|
5d5d6c2c70 | ||
|
37fa462db5 | ||
|
1a2046a7eb | ||
|
3dff7e80fc | ||
|
6eea9239a7 | ||
|
75f1969bd2 | ||
|
e97755eb91 | ||
|
b938949cdb | ||
|
447af208b3 | ||
|
d47fbbbe96 | ||
|
767b72fbfa | ||
|
b94a8da9d6 | ||
|
12b5be239b | ||
|
0fbf72bb09 | ||
|
ae2117ff5a | ||
|
b80821c4b7 | ||
|
cf01b5a002 | ||
|
bb66d559e7 | ||
|
7b8fa3b922 | ||
|
777676b525 | ||
|
28f2a1309e | ||
|
4b0a7c2252 | ||
|
2625d9f7fe | ||
|
45f24c8a85 | ||
|
5f7c11f495 | ||
|
ec4d2d65a6 | ||
|
3e20f5dd3c | ||
|
7014b5a150 | ||
|
f8427ab789 | ||
|
31fc2bfeb7 | ||
|
fb5bc16c83 | ||
|
724075e448 | ||
|
45cb9a2e80 | ||
|
456eee05f2 | ||
|
23872f77a8 | ||
|
37c1999965 | ||
|
86dd4dd784 | ||
|
00b65abd09 | ||
|
fee55fa642 | ||
|
76ea1962be | ||
|
df3cf72d29 | ||
|
32dd594f06 | ||
|
ba0ba1de94 | ||
|
660e71f032 | ||
|
169e6fdba4 | ||
|
138aeaf8c7 | ||
|
33669793b7 | ||
|
80f4bf9475 | ||
|
bed869b08e | ||
|
f2150ee7e1 | ||
|
eaf89995ee | ||
|
2311b42bca | ||
|
a4fbccac9b | ||
|
a0cf93a7ca | ||
|
f444c7d4a5 | ||
|
8ef4c12f97 | ||
|
c520c55ff4 | ||
|
6145748bfb | ||
|
1a1026b367 | ||
|
8c45bd32b7 | ||
|
2b5cee05e6 | ||
|
5442954db6 | ||
|
5ee382c8eb | ||
|
901cb44f5e | ||
|
7388461ede | ||
|
5223627b71 | ||
|
646c4a3ccc | ||
|
0b9e78df2c | ||
|
a9c24b456d | ||
|
b4463bf42c | ||
|
8f8dc66c70 | ||
|
b746250e71 | ||
|
26b7e7ec8e | ||
|
bc09760c84 | ||
|
ceb229c6ac | ||
|
1e6ac33ef1 | ||
|
86eafe7a33 | ||
|
00f46dc149 | ||
|
396c7ab9ee | ||
|
fa2cef6395 | ||
|
04638c9065 | ||
|
02bb5b6742 | ||
|
fad5fafa32 | ||
|
b0dd231018 | ||
|
0b5f005a5d | ||
|
babca8d47b | ||
|
eb462955fe | ||
|
b79db36336 | ||
|
404ea0ce6d | ||
|
d3971b26e4 | ||
|
a44a201f00 | ||
|
1d80fdddd4 | ||
|
f09745b4ad | ||
|
d13ae0610e | ||
|
3eaa447323 | ||
|
604506da10 | ||
|
122ce11381 | ||
|
8cbd9f7f08 | ||
|
7c41e5bafc | ||
|
4452f784a8 | ||
|
ced0ae0d65 | ||
|
876c51302a | ||
|
a6877e7c13 | ||
|
f633d1fa5b | ||
|
4f90b41343 | ||
|
e4ddf8bc33 | ||
|
613ab9febc | ||
|
e92cceecc1 | ||
|
3283f3ed7d | ||
|
0ed30b802d | ||
|
beefff8cce | ||
|
b1554d6a89 | ||
|
4230b03884 | ||
|
2182b8339e | ||
|
b07b77c58f | ||
|
6542407fa3 | ||
|
ebf995536b | ||
|
adcd7f10ee | ||
|
af83936047 | ||
|
c3b5b97a41 | ||
|
6c58ea18dc | ||
|
830b287e5d | ||
|
52549d51ab | ||
|
fe05ed13e5 | ||
|
3a46e7fc0a | ||
|
88674e21cf | ||
|
a0673c7028 | ||
|
592af80659 | ||
|
3ec9b3b021 | ||
|
ca2d3a192c | ||
|
209bf7d746 | ||
|
13777cc1aa | ||
|
bffc77e478 | ||
|
0ebb7eecdb | ||
|
99863bb799 | ||
|
800d2f0859 | ||
|
f397844603 | ||
|
2d895f328c | ||
|
b14b182084 | ||
|
8687d25d88 | ||
|
7001edcd1d | ||
|
4a1e88f4bf | ||
|
b41608d40b | ||
|
c5d45edf2d | ||
|
0116b6341c | ||
|
3e7ecda80f | ||
|
f0e5b2b6f9 | ||
|
5976ec9323 | ||
|
eb3463fad1 | ||
|
5f9e5869e9 | ||
|
950480bb77 | ||
|
6530ec58c7 | ||
|
b1515c5e3f | ||
|
6581f119fd | ||
|
9ad7c12710 | ||
|
8e289215b4 | ||
|
3718c3be56 | ||
|
c3c051385c | ||
|
21c688a8a8 | ||
|
668b883651 | ||
|
c396aeed52 | ||
|
40f541bc31 | ||
|
44974f98a0 | ||
|
b7cb3df9bc | ||
|
432e6d5395 | ||
|
fdf805bc7b | ||
|
73e13f3875 | ||
|
da959e1296 | ||
|
94600c54cb | ||
|
c4fc2e089d | ||
|
06444c1c27 | ||
|
f8897942f3 | ||
|
4d0b4cfb36 | ||
|
7116634739 | ||
|
36492f4857 | ||
|
3a887af513 | ||
|
3142992c57 | ||
|
68a9b88b58 | ||
|
3c801e5b91 | ||
|
ecd46f8560 | ||
|
dee8ce587d | ||
|
4c24186911 | ||
|
af360a1a20 | ||
|
b5406240c6 | ||
|
73bfbba5f7 | ||
|
46d7bfecdb | ||
|
a734927591 | ||
|
255706e173 | ||
|
b2fbf46e60 | ||
|
e37495d80b | ||
|
beb6b950f7 | ||
|
2d1c0be24e | ||
|
9941651b3c | ||
|
31fda124f3 | ||
|
b7f6498a5c | ||
|
282da1c2b6 | ||
|
8e6ec6ef0c | ||
|
704b3ee673 | ||
|
c18a1c3eca | ||
|
4e1870197e | ||
|
3bf61cce95 | ||
|
68889b0544 | ||
|
8a90a47fc2 | ||
|
c93c4cc5e6 | ||
|
06cba7defd | ||
|
8b76bbe51d | ||
|
aa1d3a4c2e | ||
|
66817411f9 | ||
|
23c3196935 | ||
|
38e73a188a | ||
|
3fdf588cc9 | ||
|
9412fe8a0a | ||
|
c6450e60e1 | ||
|
8126e9f4b1 | ||
|
70e4104c17 | ||
|
29e0e1760b | ||
|
442b7b4c4d | ||
|
548153fd5e | ||
|
5060ed8970 | ||
|
d18e064d21 | ||
|
0cfb3c7ab4 | ||
|
2e0c2f2e77 | ||
|
48f9a61ff0 | ||
|
0042e3ae02 | ||
|
a1204cf246 | ||
|
fc499d9e7c | ||
|
b83704dac2 | ||
|
b93e46de14 | ||
|
3c49aa9d9d | ||
|
a448b48eaf | ||
|
3c6551f202 | ||
|
9e0c7ed29a | ||
|
677293f3a9 | ||
|
34bd7ce3a7 | ||
|
21a07e7419 | ||
|
6b50ea6504 | ||
|
895647b908 | ||
|
0ece58b9cb | ||
|
49a56cf131 | ||
|
5fa0d798e2 | ||
|
cadc506aa5 | ||
|
eee0ccef8c | ||
|
088bd632ab | ||
|
52b5d7143b | ||
|
60bf14d4dd | ||
|
c00fb44cee | ||
|
5111880edf | ||
|
3d78b44a8e | ||
|
f2d71d41a8 | ||
|
b75b290351 | ||
|
701ae06e4a | ||
|
edd0b809b7 | ||
|
98a0d17431 | ||
|
b1bd56cd51 | ||
|
ae336da7a1 | ||
|
4a61b80dd6 | ||
|
ef99fe2d18 | ||
|
352ebc3193 | ||
|
556799428c | ||
|
0b077b9601 | ||
|
80bec9c5cf | ||
|
c24685c49a | ||
|
2b99fa81f3 | ||
|
e87443b3e4 | ||
|
74ea597bd8 | ||
|
354a42dd00 | ||
|
4cedca3427 | ||
|
e99be28a73 | ||
|
32389e4ab8 | ||
|
01d7fc0ac9 | ||
|
d74c8261aa | ||
|
ac373545d0 | ||
|
a21948d2c6 | ||
|
940480effe | ||
|
29c593b8b0 | ||
|
0c444e6f2b | ||
|
6cf6e16d22 | ||
|
abef758ff6 | ||
|
e5f9663a0e | ||
|
ff5ed561cc | ||
|
6b76270889 | ||
|
5d040f45c8 | ||
|
cebdcc71a7 | ||
|
eec14be10d | ||
|
c179936b54 | ||
|
649a565801 | ||
|
2d4ebf5eb5 | ||
|
754beed3a1 | ||
|
df5059944b | ||
|
9f0927351d | ||
|
736edf44e4 | ||
|
8ecf8eb76c | ||
|
3cd1a5b1d5 | ||
|
39507b9d0d | ||
|
dfcf9d133e | ||
|
8a74942da7 | ||
|
2fe42138c7 | ||
|
1563146918 | ||
|
cf3aea8075 | ||
|
a539dc41f3 | ||
|
6cea480210 | ||
|
3b4bb48a0f | ||
|
206717828b | ||
|
316d26ede2 | ||
|
71fd32b1f4 | ||
|
f2e471707e | ||
|
fcf3b4e4e2 | ||
|
1e735c26c4 | ||
|
7c5df5dfe3 | ||
|
5b62f91bb4 | ||
|
e8b8fb0835 | ||
|
6663ced38d | ||
|
0b03264fb0 | ||
|
c99a8a9b15 | ||
|
ea0fb15ff2 | ||
|
05a59b17be | ||
|
8b18fdd322 | ||
|
1349f584be | ||
|
48db85187e | ||
|
d1e054d713 | ||
|
ce578534fe |
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
##### Expected Behaviour:
|
||||
|
||||
|
||||
##### Actual Behaviour:
|
||||
|
||||
|
||||
##### Steps to reproduce this issue:
|
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Fixes #[issue number] .
|
||||
|
||||
Changes proposed in this pull request:
|
||||
|
||||
-
|
||||
|
||||
-
|
||||
|
||||
-
|
||||
|
||||
@pi-hole/gravity
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.DS_Store
|
8
CONTRIBUTING.md
Normal file
8
CONTRIBUTING.md
Normal file
@@ -0,0 +1,8 @@
|
||||
This is a basic checklist for now, We will update it in the future.
|
||||
|
||||
* Fork the repo and create your new branch based on the `development` branch.
|
||||
* Commit Unix line endings
|
||||
* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
|
||||
* Submit Pull Requests to the development branch only.
|
||||
* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
||||
* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..
|
40
README.md
40
README.md
@@ -1,22 +1,43 @@
|
||||
# Automated Install
|
||||
##### Designed For Raspberry Pi B, B+, 2, and Zero (with an Ethernet adapter)
|
||||
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
||||
|
||||
|
||||
[](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
1. Install Raspbian
|
||||
|
||||
2. Run the command below
|
||||
|
||||
### ```curl -L install.pi-hole.net | bash```
|
||||
### ```curl -L https://install.pi-hole.net | bash```
|
||||
|
||||
#### Alternative Semi-Automated install ####
|
||||
```
|
||||
wget -O basic-install.sh https://install.pi-hole.net
|
||||
chmod +x basic-install.sh
|
||||
./basic-install.sh
|
||||
```
|
||||
|
||||
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
|
||||
|
||||
## Pi-hole Is Free, But Powered By Your Donations
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
|
||||
|
||||
## Catch us out on the net:
|
||||
Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
||||
|
||||
reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
||||
|
||||
## How Does It Work?
|
||||
**Watch the 60-second video below to get a quick overview**
|
||||
|
||||
[](https://vimeo.com/135965232)
|
||||
|
||||
## Pi-hole Projects
|
||||
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
||||
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
|
||||
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
||||
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
||||
- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
|
||||
@@ -25,6 +46,9 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei
|
||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
||||
|
||||
## Coverage
|
||||
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
|
||||
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
|
||||
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
|
||||
- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585)
|
||||
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
|
||||
- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/)
|
||||
@@ -46,16 +70,18 @@ The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is quer
|
||||
A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0).
|
||||
|
||||
## Gravity
|
||||
The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/jacobsalmela/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
|
||||
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
|
||||
|
||||
## Whitelist and blacklist
|
||||
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/jacobsalmela/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
||||
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
||||
|
||||
## Web Interface
|
||||
The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
|
||||
|
||||
`http://192.168.1.x/admin/index.php`
|
||||
|
||||

|
||||
|
||||
### API
|
||||
|
||||
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
||||
@@ -73,12 +99,12 @@ The same output can be acheived on the CLI by running `chronometer.sh -j`
|
||||
|
||||
## Real-time Statistics
|
||||
|
||||
You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/jacobsalmela/pi-hole/blob/master/advanced/Scripts/chronometer.sh).
|
||||
You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh).
|
||||

|
||||
|
||||
## Help
|
||||
- See the [Wiki](https://github.com/jacobsalmela/pi-hole/wiki/Customization) entry for more details
|
||||
- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details
|
||||
- There is also an [FAQ section on pi-hole.net](http://pi-hole.net)
|
||||
|
||||
## Other Operating Systems
|
||||
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated.
|
||||
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi.
|
||||
|
50
adlists.default
Normal file
50
adlists.default
Normal file
@@ -0,0 +1,50 @@
|
||||
## Pi-hole ad-list default sources. Updated 21/02/2016 #########################
|
||||
# #
|
||||
# To make changes to this file: #
|
||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||
# 2. run `nano /etc/pihole/adlists.list` #
|
||||
# 3. Uncomment or comment any of the below lists #
|
||||
# #
|
||||
# Know of any other lists? Feel free to let us know about them, or add them #
|
||||
# to this file! #
|
||||
################################################################################
|
||||
|
||||
# The below list amalgamates several lists we used previously.
|
||||
# See `https://github.com/StevenBlack/hosts` for details
|
||||
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||
|
||||
# Other lists we consider safe:
|
||||
http://adblock.gjtech.net/?format=unix-hosts
|
||||
http://mirror1.malwaredomains.com/files/justdomains
|
||||
http://sysctl.org/cameleon/hosts
|
||||
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||
|
||||
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||
http://hosts-file.net/ad_servers.txt
|
||||
|
||||
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
||||
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
||||
#http://adblock.mahakala.is/
|
||||
|
||||
# ADZHOSTS list. Has been known to block legitimate domains
|
||||
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||
|
||||
# Windows 10 telemetry list
|
||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt
|
||||
|
||||
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||
#http://securemecca.com/Downloads/hosts.txt
|
||||
|
||||
# Quidsup's tracker list
|
||||
https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
||||
|
||||
# Block the BBC News website Breaking News banner
|
||||
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
||||
|
||||
|
||||
# Untested Lists:
|
||||
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||
#http://spam404bl.com/spam404scamlist.txt
|
||||
#http://malwaredomains.lehigh.edu/files/domains.txt
|
@@ -1,3 +1,14 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# dnsmasq config for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# If you want dnsmasq to read another file, as well as /etc/hosts, use
|
||||
# this.
|
||||
addn-hosts=/etc/pihole/gravity.list
|
||||
@@ -20,8 +31,8 @@ no-resolv
|
||||
|
||||
# Add other name servers here, with domain specs if they are for
|
||||
# non-public domains.
|
||||
server=8.8.8.8
|
||||
server=8.8.4.4
|
||||
server=@DNS1@
|
||||
server=@DNS2@
|
||||
|
||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||
# specified interfaces (and the loopback) give the name of the
|
139
advanced/Scripts/blacklist.sh
Normal file → Executable file
139
advanced/Scripts/blacklist.sh
Normal file → Executable file
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# This file is part of Pi-hole.
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Blacklists domains
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -8,39 +11,37 @@
|
||||
# (at your option) any later version.
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
echo "Immediately blacklists one or more domains in the hosts file"
|
||||
echo " "
|
||||
echo "Usage: blacklist.sh domain1 [domain2 ...]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
echo " -d, --delmode Remove domains from the blacklist"
|
||||
echo " -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||
echo " -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo " -q, --quiet output is less verbose"
|
||||
exit 1
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
#globals
|
||||
blacklist=/etc/pihole/blacklist.txt
|
||||
adList=/etc/pihole/gravity.list
|
||||
basename=pihole
|
||||
piholeDir=/etc/$basename
|
||||
adList=$piholeDir/gravity.list
|
||||
blacklist=$piholeDir/blacklist.txt
|
||||
reload=true
|
||||
addmode=true
|
||||
force=false
|
||||
versbose=true
|
||||
|
||||
domList=()
|
||||
domToRemoveList=()
|
||||
|
||||
|
||||
piholeIPfile=/tmp/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
|
||||
modifyHost=false
|
||||
|
||||
# After setting defaults, check if there's local overrides
|
||||
if [[ -r $piholeDir/pihole.conf ]];then
|
||||
echo "::: Local calibration requested..."
|
||||
. $piholeDir/pihole.conf
|
||||
fi
|
||||
|
||||
|
||||
if [[ -f $piholeIPv6file ]];then
|
||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||
@@ -48,12 +49,26 @@ if [[ -f $piholeIPv6file ]];then
|
||||
fi
|
||||
|
||||
|
||||
function HandleOther(){
|
||||
function helpFunc()
|
||||
{
|
||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function HandleOther(){
|
||||
#check validity of domain
|
||||
validDomain=$(echo $1 | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
|
||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
if [ -z "$validDomain" ]; then
|
||||
echo $1 is not a valid argument or domain name
|
||||
echo "::: $1 is not a valid argument or domain name"
|
||||
else
|
||||
domList=("${domList[@]}" $validDomain)
|
||||
fi
|
||||
@@ -63,13 +78,12 @@ function PopBlacklistFile(){
|
||||
#check blacklist file exists, and if not, create it
|
||||
if [[ ! -f $blacklist ]];then
|
||||
touch $blacklist
|
||||
fi
|
||||
for dom in "${domList[@]}"
|
||||
do
|
||||
if $addmode; then
|
||||
AddDomain $dom
|
||||
fi
|
||||
for dom in "${domList[@]}"; do
|
||||
if "$addmode"; then
|
||||
AddDomain "$dom"
|
||||
else
|
||||
RemoveDomain $dom
|
||||
RemoveDomain "$dom"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -81,75 +95,82 @@ function AddDomain(){
|
||||
if $bool; then
|
||||
#domain not found in the blacklist file, add it!
|
||||
if $versbose; then
|
||||
echo "** Adding $1 to blacklist file"
|
||||
echo -n "::: Adding $1 to blacklist file..."
|
||||
fi
|
||||
echo $1 >> $blacklist
|
||||
echo "$1" >> $blacklist
|
||||
modifyHost=true
|
||||
echo " done!"
|
||||
else
|
||||
if $versbose; then
|
||||
echo "** $1 already blacklisted! No need to add"
|
||||
echo "::: $1 already exists in $blacklist! No need to add"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function RemoveDomain(){
|
||||
|
||||
|
||||
bool=false
|
||||
grep -Ex -q "$1" $blacklist || bool=true
|
||||
if $bool; then
|
||||
#Domain is not in the blacklist file, no need to Remove
|
||||
if $versbose; then
|
||||
echo "** $1 is NOT blacklisted! No need to remove"
|
||||
echo "::: $1 is NOT blacklisted! No need to remove"
|
||||
fi
|
||||
else
|
||||
#Domain is in the blacklist file, add to a temporary array
|
||||
if $versbose; then
|
||||
echo "** Un-blacklisting $dom..."
|
||||
echo "::: Un-blacklisting $dom..."
|
||||
fi
|
||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||
modifyHost=true
|
||||
fi
|
||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||
modifyHost=true
|
||||
fi
|
||||
}
|
||||
|
||||
function ModifyHostFile(){
|
||||
function ModifyHostFile(){
|
||||
if $addmode; then
|
||||
#add domains to the hosts file
|
||||
if [[ -r $blacklist ]];then
|
||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||
echo "** blacklisting a total of $numberOf domain${plural}..."
|
||||
echo ":::"
|
||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||
else
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||
fi
|
||||
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||
else
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
||||
for dom in "${domToRemoveList[@]}"
|
||||
do
|
||||
#we need to remove the domains from the blacklist file and the host file
|
||||
echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||
echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
||||
done
|
||||
fi
|
||||
|
||||
echo ":::"
|
||||
for dom in "${domToRemoveList[@]}"
|
||||
do
|
||||
#we need to remove the domains from the blacklist file and the host file
|
||||
echo "::: $dom"
|
||||
echo -n "::: removing from HOSTS file..."
|
||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||
echo " done!"
|
||||
echo -n "::: removing from blackist.txt..."
|
||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
||||
echo " done!"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function Reload() {
|
||||
# Reload hosts file
|
||||
echo "** Refresh lists in dnsmasq..."
|
||||
echo ":::"
|
||||
echo -n "::: Refresh lists in dnsmasq..."
|
||||
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
sudo kill -HUP $dnsmasqPid
|
||||
sudo kill -HUP "$dnsmasqPid"
|
||||
else
|
||||
# service not running, start it up
|
||||
sudo service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
###################################################
|
||||
@@ -157,22 +178,22 @@ function Reload() {
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-d" | "--delmode" ) addmode=false;;
|
||||
"-f" | "--force" ) force=true;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
* ) HandleOther $var;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
* ) HandleOther "$var";;
|
||||
esac
|
||||
done
|
||||
|
||||
PopBlacklistFile
|
||||
|
||||
if $modifyHost || $force; then
|
||||
echo "** Modifying Hosts File"
|
||||
ModifyHostFile
|
||||
else
|
||||
if $versbose; then
|
||||
echo "** No changes need to be made"
|
||||
echo "::: No changes need to be made"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# This file is part of Pi-hole.
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Calculates stats and displays to an LCD
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -48,9 +51,13 @@ function CalcblockedToday(){
|
||||
|
||||
function CalcPercentBlockedToday(){
|
||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
||||
else
|
||||
percentBlockedToday=0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -66,9 +73,9 @@ function outputJSON(){
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
|
||||
|
||||
CalcBlockedDomains
|
||||
|
||||
|
||||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||
}
|
||||
|
||||
@@ -81,43 +88,45 @@ function normalChrono(){
|
||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||
echo ""
|
||||
uptime | cut -d' ' -f11-
|
||||
#uptime -p #Doesn't work on all versions of uptime
|
||||
uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'
|
||||
echo "-------------------------------"
|
||||
# Uncomment to continually read the log file and display the current domain being blocked
|
||||
#tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'
|
||||
|
||||
|
||||
#uncomment next 4 lines to use original query count calculation
|
||||
#today=$(date "+%b %e")
|
||||
#todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l)
|
||||
#todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l)
|
||||
#todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l)
|
||||
|
||||
|
||||
|
||||
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
|
||||
|
||||
CalcBlockedDomains
|
||||
|
||||
|
||||
echo "Blocking: $blockedDomainsTotal"
|
||||
#below commented line does not add up to todaysQueryCount
|
||||
#echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6"
|
||||
echo "Queries: $queriesToday" #same total calculation as dashboard
|
||||
echo "Pi-holed: $blockedToday ($percentBlockedToday%)"
|
||||
|
||||
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
function displayHelp(){
|
||||
echo "Displays stats about your piHole!"
|
||||
echo " "
|
||||
echo "Usage: chronometer.sh [optional:-j]"
|
||||
echo "Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
echo " -j, --json output stats as JSON formatted string"
|
||||
echo " -h, --help display this help text"
|
||||
|
||||
echo "::: Displays stats about your piHole!"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -c [optional:-j]"
|
||||
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -j, --json output stats as JSON formatted string"
|
||||
echo "::: -h, --help display this help text"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -129,7 +138,7 @@ for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-j" | "--json" ) outputJSON;;
|
||||
"-h" | "--help" ) displayHelp;;
|
||||
"-h" | "--help" ) displayHelp;;
|
||||
* ) exit 1;;
|
||||
esac
|
||||
done
|
||||
|
310
advanced/Scripts/piholeDebug.sh
Executable file
310
advanced/Scripts/piholeDebug.sh
Executable file
@@ -0,0 +1,310 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Generates pihole_debug.log in /var/log/ to be used for troubleshooting.
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Nate Brandeburg
|
||||
# nate@ubiquisoft.com
|
||||
# 3/24/2016
|
||||
|
||||
######## GLOBAL VARS ########
|
||||
DEBUG_LOG="/var/log/pihole_debug.log"
|
||||
DNSMASQFILE="/etc/dnsmasq.conf"
|
||||
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
||||
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
||||
GRAVITYFILE="/etc/pihole/gravity.list"
|
||||
HOSTSFILE="/etc/hosts"
|
||||
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
||||
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
||||
ADLISTSFILE="/etc/pihole/adlists.list"
|
||||
PIHOLELOG="/var/log/pihole.log"
|
||||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||
|
||||
|
||||
######## FIRST CHECK ########
|
||||
# Must be root to debug
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "::: You are root... Beginning debug!"
|
||||
else
|
||||
echo "::: Sudo will be used for debugging."
|
||||
# Check if sudo is actually installed
|
||||
if [[ $(dpkg-query -s sudo) ]]; then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure the file exists, create if not, clear if exists.
|
||||
if [ ! -f "$DEBUG_LOG" ]; then
|
||||
$SUDO touch $DEBUG_LOG
|
||||
$SUDO chmod 644 $DEBUG_LOG
|
||||
$SUDO chown "$USER":root $DEBUG_LOG
|
||||
else
|
||||
truncate -s 0 $DEBUG_LOG
|
||||
fi
|
||||
|
||||
### Private functions exist here ###
|
||||
function compareWhitelist {
|
||||
if [ ! -f "$WHITELISTMATCHES" ]; then
|
||||
$SUDO touch $WHITELISTMATCHES
|
||||
$SUDO chmod 644 $WHITELISTMATCHES
|
||||
$SUDO chown "$USER":root $WHITELISTMATCHES
|
||||
else
|
||||
truncate -s 0 $WHITELISTMATCHES
|
||||
fi
|
||||
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "######## Whitelist Comparison #########" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
TMP=$(grep -w ".* $line$" "$GRAVITYFILE")
|
||||
if [ ! -z "$TMP" ]; then
|
||||
echo "$TMP" >> $DEBUG_LOG
|
||||
echo "$TMP" >> $WHITELISTMATCHES
|
||||
fi
|
||||
done < "$WHITELISTFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
}
|
||||
|
||||
function compareBlacklist {
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$BLACKLISTFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
}
|
||||
|
||||
function testNslookup {
|
||||
TESTURL="doubleclick.com"
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ NSLookup Test ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
# Find a blocked url that has not been whitelisted.
|
||||
if [ -s "$WHITELISTMATCHES" ]; then
|
||||
while read -r line; do
|
||||
CUTURL=${line#*" "}
|
||||
if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then
|
||||
while read -r line2; do
|
||||
CUTURL2=${line2#*" "}
|
||||
if [ "$CUTURL" != "$CUTURL2" ]; then
|
||||
TESTURL="$CUTURL"
|
||||
break 2
|
||||
fi
|
||||
done < "$WHITELISTMATCHES"
|
||||
fi
|
||||
done < "$GRAVITYFILE"
|
||||
fi
|
||||
|
||||
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG
|
||||
nslookup "$TESTURL" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG
|
||||
nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
}
|
||||
|
||||
function checkProcesses {
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "########### Processes Check ###########" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo ":::"
|
||||
echo "::: Logging status of lighttpd and dnsmasq..."
|
||||
PROCESSES=( lighttpd dnsmasq )
|
||||
for i in "${PROCESSES[@]}"
|
||||
do
|
||||
echo "" >> $DEBUG_LOG
|
||||
echo -n $i >> "$DEBUG_LOG"
|
||||
echo " processes status:" >> $DEBUG_LOG
|
||||
$SUDO systemctl -l status $i >> "$DEBUG_LOG"
|
||||
done
|
||||
}
|
||||
|
||||
### END FUNCTIONS ###
|
||||
|
||||
### Check Pi internet connections ###
|
||||
# Log the IP addresses of this Pi
|
||||
IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e')
|
||||
echo "::: Writing local IPs to debug log"
|
||||
echo "IP Addresses of this Pi:" >> $DEBUG_LOG
|
||||
echo "$IPADDR" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
|
||||
# Check if we can connect to the local gateway
|
||||
GATEWAY_CHECK=$(ping -q -w 1 -c 1 "$(ip r | grep default | cut -d ' ' -f 3)" > /dev/null && echo ok || echo error)
|
||||
echo "Gateway check:" >> $DEBUG_LOG
|
||||
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
|
||||
compareWhitelist
|
||||
compareBlacklist
|
||||
testNslookup
|
||||
checkProcesses
|
||||
|
||||
echo "::: Writing dnsmasq.conf to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############### Dnsmasq ###############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$DNSMASQFILE" ]
|
||||
then
|
||||
#cat $DNSMASQFILE >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
echo "$line" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$DNSMASQFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No dnsmasq.conf file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo dnsmasq.conf file found!\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing 01-pihole.conf to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$PIHOLECONFFILE" ]
|
||||
then
|
||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
echo "$line" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$PIHOLECONFFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No 01-pihole.conf file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo 01-pihole.conf file found\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing lighttpd.conf to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$LIGHTTPDFILE" ]
|
||||
then
|
||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
echo "$line" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$LIGHTTPDFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo lighttpd.conf file found\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing size of gravity.list to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ gravity.list #############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$GRAVITYFILE" ]
|
||||
then
|
||||
wc -l "$GRAVITYFILE" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No gravity.list file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo gravity.list file found\n"
|
||||
fi
|
||||
|
||||
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
|
||||
echo "Hostname of this pihole is: " >> $DEBUG_LOG
|
||||
hostname >> $DEBUG_LOG
|
||||
|
||||
echo "::: Writing hosts file to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "################ Hosts ################" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$HOSTSFILE" ]
|
||||
then
|
||||
cat "$HOSTSFILE" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No hosts file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo hosts file found!\n"
|
||||
fi
|
||||
|
||||
### PiHole application specific logging ###
|
||||
echo "::: Writing whitelist to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############## Whitelist ##############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$WHITELISTFILE" ]
|
||||
then
|
||||
cat "$WHITELISTFILE" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No whitelist.txt file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo whitelist.txt file found!\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing blacklist to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############## Blacklist ##############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$BLACKLISTFILE" ]
|
||||
then
|
||||
cat "$BLACKLISTFILE" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No blacklist.txt file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo blacklist.txt file found!\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing adlists.list to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ adlists.list #############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$ADLISTSFILE" ]
|
||||
then
|
||||
cat "$ADLISTSFILE" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No adlists.list file found... using adlists.default!" >> $DEBUG_LOG
|
||||
printf ":::\tNo adlists.list file found... using adlists.default!\n"
|
||||
fi
|
||||
|
||||
|
||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||
function dumpPiHoleLog {
|
||||
trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$PIHOLELOG" ]
|
||||
then
|
||||
while true; do
|
||||
tail -f "$PIHOLELOG" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
done
|
||||
else
|
||||
echo "No pihole.log file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo pihole.log file found!\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# Anything to be done after capturing of pihole.log terminates
|
||||
function finalWork {
|
||||
echo "::: Finshed debugging!"
|
||||
}
|
||||
trap finalWork EXIT
|
||||
|
||||
### Method calls for additional logging ###
|
||||
dumpPiHoleLog
|
@@ -1,11 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Flushes /var/log/pihole.log
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# This file is part of Pi-hole.
|
||||
#
|
||||
#Pi-hole is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU General Public License as published by
|
||||
#the Free Software Foundation, either version 2 of the License, or
|
||||
#(at your option) any later version.
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||
truncate -s 0 /var/log/pihole.log
|
||||
echo "... done!"
|
||||
|
89
advanced/Scripts/setupLCD.sh
Executable file
89
advanced/Scripts/setupLCD.sh
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Automatically configures the Pi to use the 2.8 LCD screen to display stats on it (also works over ssh)
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
############ FUNCTIONS ###########
|
||||
# Run this script as root or under sudo
|
||||
echo ":::"
|
||||
if [[ $EUID -eq 0 ]];then
|
||||
echo "::: You are root."
|
||||
else
|
||||
echo "::: sudo will be used."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the install cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
|
||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
||||
getInitSys() {
|
||||
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
|
||||
SYSTEMD=1
|
||||
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
|
||||
SYSTEMD=0
|
||||
else
|
||||
echo "Unrecognised init system"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Borrowed from adafruit-pitft-helper:
|
||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
||||
autoLoginPiToConsole() {
|
||||
if [ -e /etc/init.d/lightdm ]; then
|
||||
if [ $SYSTEMD -eq 1 ]; then
|
||||
$SUDO systemctl set-default multi-user.target
|
||||
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||||
else
|
||||
$SUDO update-rc.d lightdm disable 2
|
||||
$SUDO sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
######### SCRIPT ###########
|
||||
# Set pi to log in automatically
|
||||
getInitSys
|
||||
autoLoginPiToConsole
|
||||
|
||||
# Set chronomter to run automatically when pi logs in
|
||||
echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
|
||||
# OR
|
||||
#$SUDO echo /usr/local/bin/chronometer.sh >> /etc/profile
|
||||
|
||||
# Set up the LCD screen based on Adafruits instuctions:
|
||||
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
|
||||
curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash
|
||||
$SUDO apt-get -y install raspberrypi-bootloader
|
||||
$SUDO apt-get -y install adafruit-pitft-helper
|
||||
$SUDO adafruit-pitft-helper -t 28r
|
||||
|
||||
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
|
||||
$SUDO mv /boot/cmdline.txt /boot/cmdline.orig
|
||||
$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
|
||||
|
||||
# Back up the original file and download the new one
|
||||
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig
|
||||
$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
|
||||
|
||||
# Instantly apply the font change to the LCD screen
|
||||
$SUDO setupcon
|
||||
|
||||
$SUDO reboot
|
||||
|
||||
# Start showing the stats on the screen by running the command on another tty:
|
||||
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
|
||||
#setsid sh -c 'exec /usr/local/bin/chronometer.sh <> /dev/tty1 >&0 2>&1'
|
23
advanced/Scripts/updateDashboard.sh
Normal file → Executable file
23
advanced/Scripts/updateDashboard.sh
Normal file → Executable file
@@ -1,17 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Updates the Pi-hole web interface
|
||||
#
|
||||
# this script will update the pihole web interface files.
|
||||
#
|
||||
# if this is the first time running this script after an
|
||||
# existing installation, the existing web interface files
|
||||
# will be removed and replaced with the latest master
|
||||
# branch from github. subsequent executions of this script
|
||||
# will pull the latest version of the web interface.
|
||||
#
|
||||
# @TODO: add git as requirement to basic-install.sh
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
WEB_INTERFACE_GIT_URL="https://github.com/jacobsalmela/AdminLTE.git"
|
||||
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
||||
WEB_INTERFACE_DIR="/var/www/html/admin"
|
||||
|
||||
main() {
|
||||
@@ -64,7 +63,7 @@ make_repo() {
|
||||
update_repo() {
|
||||
# pull the latest commits
|
||||
cd "$WEB_INTERFACE_DIR"
|
||||
git pull
|
||||
git pull
|
||||
}
|
||||
|
||||
main
|
||||
|
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# This file is part of Pi-hole.
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Whitelists domains
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -8,38 +11,36 @@
|
||||
# (at your option) any later version.
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
echo "Immediately whitelists one or more domains in the hosts file"
|
||||
echo " "
|
||||
echo "Usage: whitelist.sh domain1 [domain2 ...]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
echo " -d, --delmode Remove domains from the whitelist"
|
||||
echo " -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||
echo " -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo " -q, --quiet output is less verbose"
|
||||
exit 1
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
#globals
|
||||
whitelist=/etc/pihole/whitelist.txt
|
||||
adList=/etc/pihole/gravity.list
|
||||
basename=pihole
|
||||
piholeDir=/etc/$basename
|
||||
adList=$piholeDir/gravity.list
|
||||
whitelist=$piholeDir/whitelist.txt
|
||||
reload=true
|
||||
addmode=true
|
||||
force=false
|
||||
versbose=true
|
||||
|
||||
domList=()
|
||||
domToRemoveList=()
|
||||
|
||||
piholeIPfile=/tmp/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
|
||||
modifyHost=false
|
||||
|
||||
# After setting defaults, check if there's local overrides
|
||||
if [[ -r $piholeDir/pihole.conf ]];then
|
||||
echo "::: Local calibration requested..."
|
||||
. $piholeDir/pihole.conf
|
||||
fi
|
||||
|
||||
if [[ -f $piholeIPv6file ]];then
|
||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||
@@ -47,13 +48,27 @@ if [[ -f $piholeIPv6file ]];then
|
||||
fi
|
||||
|
||||
|
||||
function HandleOther(){
|
||||
function helpFunc()
|
||||
{
|
||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function HandleOther(){
|
||||
#check validity of domain
|
||||
validDomain=$(echo $1 | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
|
||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
if [ -z "$validDomain" ]; then
|
||||
echo $1 is not a valid argument or domain name
|
||||
else
|
||||
echo "::: $1 is not a valid argument or domain name"
|
||||
else
|
||||
domList=("${domList[@]}" $validDomain)
|
||||
fi
|
||||
}
|
||||
@@ -62,13 +77,13 @@ function PopWhitelistFile(){
|
||||
#check whitelist file exists, and if not, create it
|
||||
if [[ ! -f $whitelist ]];then
|
||||
touch $whitelist
|
||||
fi
|
||||
fi
|
||||
for dom in "${domList[@]}"
|
||||
do
|
||||
do
|
||||
if $addmode; then
|
||||
AddDomain $dom
|
||||
AddDomain "$dom"
|
||||
else
|
||||
RemoveDomain $dom
|
||||
RemoveDomain "$dom"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -76,78 +91,99 @@ function PopWhitelistFile(){
|
||||
function AddDomain(){
|
||||
#| sed 's/\./\\./g'
|
||||
bool=false
|
||||
|
||||
grep -Ex -q "$1" $whitelist || bool=true
|
||||
if $bool; then
|
||||
#domain not found in the whitelist file, add it!
|
||||
if $versbose; then
|
||||
echo "** Adding $1 to whitelist file"
|
||||
echo -n "::: Adding $1 to $whitelist..."
|
||||
fi
|
||||
echo $1 >> $whitelist
|
||||
echo "$1" >> $whitelist
|
||||
modifyHost=true
|
||||
if $versbose; then
|
||||
echo " done!"
|
||||
fi
|
||||
else
|
||||
if $versbose; then
|
||||
echo "** $1 already whitelisted! No need to add"
|
||||
echo "::: $1 already exists in $whitelist, no need to add!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function RemoveDomain(){
|
||||
|
||||
|
||||
bool=false
|
||||
grep -Ex -q "$1" $whitelist || bool=true
|
||||
if $bool; then
|
||||
#Domain is not in the whitelist file, no need to Remove
|
||||
if $versbose; then
|
||||
echo "** $1 is NOT whitelisted! No need to remove"
|
||||
echo "::: $1 is NOT whitelisted! No need to remove"
|
||||
fi
|
||||
else
|
||||
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file
|
||||
if $versbose; then
|
||||
echo "** Un-whitelisting $dom..."
|
||||
fi
|
||||
#if $versbose; then
|
||||
#echo "::: Un-whitelisting $dom..."
|
||||
#fi
|
||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||
modifyHost=true
|
||||
fi
|
||||
modifyHost=true
|
||||
fi
|
||||
}
|
||||
|
||||
function ModifyHostFile(){
|
||||
function ModifyHostFile(){
|
||||
if $addmode; then
|
||||
#remove domains in from hosts file
|
||||
if [[ -r $whitelist ]];then
|
||||
# Remove whitelist entries
|
||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||
echo "** Whitelisting a total of $numberOf domain${plural}..."
|
||||
awk -F':' '{ print $1 }' $whitelist | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||
echo ":::"
|
||||
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
||||
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
|
||||
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
|
||||
echo "l" >> /etc/pihole/whitelist.tmp
|
||||
grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp
|
||||
rm $adList
|
||||
mv $piholeDir/gravity.tmp $adList
|
||||
rm $piholeDir/whitelist.tmp
|
||||
echo " done!"
|
||||
|
||||
fi
|
||||
else
|
||||
#we need to add the removed domains to the hosts file
|
||||
echo ":::"
|
||||
echo "::: Modifying HOSTS file to un-whitelist domains..."
|
||||
for rdom in "${domToRemoveList[@]}"
|
||||
do
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
echo "**Blacklisting $rdom on IPv4 and IPv6"
|
||||
echo $rdom | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..."
|
||||
echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||
echo " done!"
|
||||
else
|
||||
echo "**Blacklisting $rdom on IPv4"
|
||||
echo $rdom | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||
fi
|
||||
echo $rdom| sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
||||
echo -n "::: Un-whitelisting $rdom on IPv4"
|
||||
echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||
echo " done!"
|
||||
fi
|
||||
echo -n "::: Removing $rdom from $whitelist..."
|
||||
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
||||
echo " done!"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function Reload() {
|
||||
# Reload hosts file
|
||||
echo "** Refresh lists in dnsmasq..."
|
||||
echo ":::"
|
||||
echo -n "::: Refresh lists in dnsmasq..."
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
sudo kill -HUP $dnsmasqPid
|
||||
sudo kill -HUP "$dnsmasqPid"
|
||||
else
|
||||
# service not running, start it up
|
||||
sudo service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
###################################################
|
||||
@@ -155,22 +191,23 @@ function Reload() {
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-d" | "--delmode" ) addmode=false;;
|
||||
"-f" | "--force" ) force=true;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
* ) HandleOther $var;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
* ) HandleOther "$var";;
|
||||
esac
|
||||
done
|
||||
|
||||
PopWhitelistFile
|
||||
|
||||
if $modifyHost || $force; then
|
||||
echo "** Modifying Hosts File"
|
||||
ModifyHostFile
|
||||
ModifyHostFile
|
||||
else
|
||||
if $versbose; then
|
||||
echo "** No changes need to be made"
|
||||
echo ":::"
|
||||
echo "::: No changes need to be made"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
12
advanced/bash-completion/pihole
Normal file
12
advanced/bash-completion/pihole
Normal file
@@ -0,0 +1,12 @@
|
||||
_pihole()
|
||||
{
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer uninstall help"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
complete -F _pihole pihole
|
1
advanced/cmdline.txt
Normal file
1
advanced/cmdline.txt
Normal file
@@ -0,0 +1 @@
|
||||
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=font:VGA8x8 consoleblank=0
|
17
advanced/console-setup
Normal file
17
advanced/console-setup
Normal file
@@ -0,0 +1,17 @@
|
||||
# CONFIGURATION FILE FOR SETUPCON
|
||||
|
||||
# Consult the console-setup(5) manual page.
|
||||
|
||||
ACTIVE_CONSOLES="/dev/tty[1-6]"
|
||||
|
||||
CHARMAP="UTF-8"
|
||||
|
||||
# For best results with the Adafruit 2.8 LCD and Pi-hole's chronometer
|
||||
CODESET="guess"
|
||||
FONTFACE="Terminus"
|
||||
FONTSIZE="10x20"
|
||||
|
||||
VIDEOMODE=
|
||||
|
||||
# The following is an example how to use a braille font
|
||||
# FONT='lat9w-08.psf.gz brl-8x8.psf'
|
648
advanced/dnsmasq.conf.original
Normal file
648
advanced/dnsmasq.conf.original
Normal file
@@ -0,0 +1,648 @@
|
||||
# Configuration file for dnsmasq.
|
||||
#
|
||||
# Format is one option per line, legal options are the same
|
||||
# as the long options legal on the command line. See
|
||||
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
|
||||
|
||||
# Listen on this specific port instead of the standard DNS port
|
||||
# (53). Setting this to zero completely disables DNS function,
|
||||
# leaving only DHCP and/or TFTP.
|
||||
#port=5353
|
||||
|
||||
# The following two options make you a better netizen, since they
|
||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||
# answer, and which load the servers (especially the root servers)
|
||||
# unnecessarily. If you have a dial-on-demand link they also stop
|
||||
# these requests from bringing up the link unnecessarily.
|
||||
|
||||
# Never forward plain names (without a dot or domain part)
|
||||
#domain-needed
|
||||
# Never forward addresses in the non-routed address spaces.
|
||||
#bogus-priv
|
||||
|
||||
# Uncomment these to enable DNSSEC validation and caching:
|
||||
# (Requires dnsmasq to be built with DNSSEC option.)
|
||||
#conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
|
||||
#dnssec
|
||||
|
||||
# Replies which are not DNSSEC signed may be legitimate, because the domain
|
||||
# is unsigned, or may be forgeries. Setting this option tells dnsmasq to
|
||||
# check that an unsigned reply is OK, by finding a secure proof that a DS
|
||||
# record somewhere between the root and the domain does not exist.
|
||||
# The cost of setting this is that even queries in unsigned domains will need
|
||||
# one or more extra DNS queries to verify.
|
||||
#dnssec-check-unsigned
|
||||
|
||||
# Uncomment this to filter useless windows-originated DNS requests
|
||||
# which can trigger dial-on-demand links needlessly.
|
||||
# Note that (amongst other things) this blocks all SRV requests,
|
||||
# so don't use it if you use eg Kerberos, SIP, XMMP or Google-talk.
|
||||
# This option only affects forwarding, SRV records originating for
|
||||
# dnsmasq (via srv-host= lines) are not suppressed by it.
|
||||
#filterwin2k
|
||||
|
||||
# Change this line if you want dns to get its upstream servers from
|
||||
# somewhere other that /etc/resolv.conf
|
||||
#resolv-file=
|
||||
|
||||
# By default, dnsmasq will send queries to any of the upstream
|
||||
# servers it knows about and tries to favour servers to are known
|
||||
# to be up. Uncommenting this forces dnsmasq to try each query
|
||||
# with each server strictly in the order they appear in
|
||||
# /etc/resolv.conf
|
||||
#strict-order
|
||||
|
||||
# If you don't want dnsmasq to read /etc/resolv.conf or any other
|
||||
# file, getting its servers from this file instead (see below), then
|
||||
# uncomment this.
|
||||
#no-resolv
|
||||
|
||||
# If you don't want dnsmasq to poll /etc/resolv.conf or other resolv
|
||||
# files for changes and re-read them then uncomment this.
|
||||
#no-poll
|
||||
|
||||
# Add other name servers here, with domain specs if they are for
|
||||
# non-public domains.
|
||||
#server=/localnet/192.168.0.1
|
||||
|
||||
# Example of routing PTR queries to nameservers: this will send all
|
||||
# address->name queries for 192.168.3/24 to nameserver 10.1.2.3
|
||||
#server=/3.168.192.in-addr.arpa/10.1.2.3
|
||||
|
||||
# Add local-only domains here, queries in these domains are answered
|
||||
# from /etc/hosts or DHCP only.
|
||||
#local=/localnet/
|
||||
|
||||
# Add domains which you want to force to an IP address here.
|
||||
# The example below send any host in double-click.net to a local
|
||||
# web-server.
|
||||
#address=/double-click.net/127.0.0.1
|
||||
|
||||
# --address (and --server) work with IPv6 addresses too.
|
||||
#address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
|
||||
|
||||
# Add the IPs of all queries to yahoo.com, google.com, and their
|
||||
# subdomains to the vpn and search ipsets:
|
||||
#ipset=/yahoo.com/google.com/vpn,search
|
||||
|
||||
# You can control how dnsmasq talks to a server: this forces
|
||||
# queries to 10.1.2.3 to be routed via eth1
|
||||
# server=10.1.2.3@eth1
|
||||
|
||||
# and this sets the source (ie local) address used to talk to
|
||||
# 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
|
||||
# IP on the machine, obviously).
|
||||
# server=10.1.2.3@192.168.1.1#55
|
||||
|
||||
# If you want dnsmasq to change uid and gid to something other
|
||||
# than the default, edit the following lines.
|
||||
#user=
|
||||
#group=
|
||||
|
||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||
# specified interfaces (and the loopback) give the name of the
|
||||
# interface (eg eth0) here.
|
||||
# Repeat the line for more than one interface.
|
||||
#interface=
|
||||
# Or you can specify which interface _not_ to listen on
|
||||
#except-interface=
|
||||
# Or which to listen on by address (remember to include 127.0.0.1 if
|
||||
# you use this.)
|
||||
#listen-address=
|
||||
# If you want dnsmasq to provide only DNS service on an interface,
|
||||
# configure it as shown above, and then use the following line to
|
||||
# disable DHCP and TFTP on it.
|
||||
#no-dhcp-interface=
|
||||
|
||||
# On systems which support it, dnsmasq binds the wildcard address,
|
||||
# even when it is listening on only some interfaces. It then discards
|
||||
# requests that it shouldn't reply to. This has the advantage of
|
||||
# working even when interfaces come and go and change address. If you
|
||||
# want dnsmasq to really bind only the interfaces it is listening on,
|
||||
# uncomment this option. About the only time you may need this is when
|
||||
# running another nameserver on the same machine.
|
||||
#bind-interfaces
|
||||
|
||||
# If you don't want dnsmasq to read /etc/hosts, uncomment the
|
||||
# following line.
|
||||
#no-hosts
|
||||
# or if you want it to read another file, as well as /etc/hosts, use
|
||||
# this.
|
||||
#addn-hosts=/etc/banner_add_hosts
|
||||
|
||||
# Set this (and domain: see below) if you want to have a domain
|
||||
# automatically added to simple names in a hosts-file.
|
||||
#expand-hosts
|
||||
|
||||
# Set the domain for dnsmasq. this is optional, but if it is set, it
|
||||
# does the following things.
|
||||
# 1) Allows DHCP hosts to have fully qualified domain names, as long
|
||||
# as the domain part matches this setting.
|
||||
# 2) Sets the "domain" DHCP option thereby potentially setting the
|
||||
# domain of all systems configured by DHCP
|
||||
# 3) Provides the domain part for "expand-hosts"
|
||||
#domain=thekelleys.org.uk
|
||||
|
||||
# Set a different domain for a particular subnet
|
||||
#domain=wireless.thekelleys.org.uk,192.168.2.0/24
|
||||
|
||||
# Same idea, but range rather then subnet
|
||||
#domain=reserved.thekelleys.org.uk,192.68.3.100,192.168.3.200
|
||||
|
||||
# Uncomment this to enable the integrated DHCP server, you need
|
||||
# to supply the range of addresses available for lease and optionally
|
||||
# a lease time. If you have more than one network, you will need to
|
||||
# repeat this for each network on which you want to supply DHCP
|
||||
# service.
|
||||
#dhcp-range=192.168.0.50,192.168.0.150,12h
|
||||
|
||||
# This is an example of a DHCP range where the netmask is given. This
|
||||
# is needed for networks we reach the dnsmasq DHCP server via a relay
|
||||
# agent. If you don't know what a DHCP relay agent is, you probably
|
||||
# don't need to worry about this.
|
||||
#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h
|
||||
|
||||
# This is an example of a DHCP range which sets a tag, so that
|
||||
# some DHCP options may be set only for this network.
|
||||
#dhcp-range=set:red,192.168.0.50,192.168.0.150
|
||||
|
||||
# Use this DHCP range only when the tag "green" is set.
|
||||
#dhcp-range=tag:green,192.168.0.50,192.168.0.150,12h
|
||||
|
||||
# Specify a subnet which can't be used for dynamic address allocation,
|
||||
# is available for hosts with matching --dhcp-host lines. Note that
|
||||
# dhcp-host declarations will be ignored unless there is a dhcp-range
|
||||
# of some type for the subnet in question.
|
||||
# In this case the netmask is implied (it comes from the network
|
||||
# configuration on the machine running dnsmasq) it is possible to give
|
||||
# an explicit netmask instead.
|
||||
#dhcp-range=192.168.0.0,static
|
||||
|
||||
# Enable DHCPv6. Note that the prefix-length does not need to be specified
|
||||
# and defaults to 64 if missing/
|
||||
#dhcp-range=1234::2, 1234::500, 64, 12h
|
||||
|
||||
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
||||
#dhcp-range=1234::, ra-only
|
||||
|
||||
# Do Router Advertisements, BUT NOT DHCP for this subnet, also try and
|
||||
# add names to the DNS for the IPv6 address of SLAAC-configured dual-stack
|
||||
# hosts. Use the DHCPv4 lease to derive the name, network segment and
|
||||
# MAC address and assume that the host will also have an
|
||||
# IPv6 address calculated using the SLAAC alogrithm.
|
||||
#dhcp-range=1234::, ra-names
|
||||
|
||||
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
||||
# Set the lifetime to 46 hours. (Note: minimum lifetime is 2 hours.)
|
||||
#dhcp-range=1234::, ra-only, 48h
|
||||
|
||||
# Do DHCP and Router Advertisements for this subnet. Set the A bit in the RA
|
||||
# so that clients can use SLAAC addresses as well as DHCP ones.
|
||||
#dhcp-range=1234::2, 1234::500, slaac
|
||||
|
||||
# Do Router Advertisements and stateless DHCP for this subnet. Clients will
|
||||
# not get addresses from DHCP, but they will get other configuration information.
|
||||
# They will use SLAAC for addresses.
|
||||
#dhcp-range=1234::, ra-stateless
|
||||
|
||||
# Do stateless DHCP, SLAAC, and generate DNS names for SLAAC addresses
|
||||
# from DHCPv4 leases.
|
||||
#dhcp-range=1234::, ra-stateless, ra-names
|
||||
|
||||
# Do router advertisements for all subnets where we're doing DHCPv6
|
||||
# Unless overriden by ra-stateless, ra-names, et al, the router
|
||||
# advertisements will have the M and O bits set, so that the clients
|
||||
# get addresses and configuration from DHCPv6, and the A bit reset, so the
|
||||
# clients don't use SLAAC addresses.
|
||||
#enable-ra
|
||||
|
||||
# Supply parameters for specified hosts using DHCP. There are lots
|
||||
# of valid alternatives, so we will give examples of each. Note that
|
||||
# IP addresses DO NOT have to be in the range given above, they just
|
||||
# need to be on the same network. The order of the parameters in these
|
||||
# do not matter, it's permissible to give name, address and MAC in any
|
||||
# order.
|
||||
|
||||
# Always allocate the host with Ethernet address 11:22:33:44:55:66
|
||||
# The IP address 192.168.0.60
|
||||
#dhcp-host=11:22:33:44:55:66,192.168.0.60
|
||||
|
||||
# Always set the name of the host with hardware address
|
||||
# 11:22:33:44:55:66 to be "fred"
|
||||
#dhcp-host=11:22:33:44:55:66,fred
|
||||
|
||||
# Always give the host with Ethernet address 11:22:33:44:55:66
|
||||
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
|
||||
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
|
||||
|
||||
# Give a host with Ethernet address 11:22:33:44:55:66 or
|
||||
# 12:34:56:78:90:12 the IP address 192.168.0.60. Dnsmasq will assume
|
||||
# that these two Ethernet interfaces will never be in use at the same
|
||||
# time, and give the IP address to the second, even if it is already
|
||||
# in use by the first. Useful for laptops with wired and wireless
|
||||
# addresses.
|
||||
#dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.60
|
||||
|
||||
# Give the machine which says its name is "bert" IP address
|
||||
# 192.168.0.70 and an infinite lease
|
||||
#dhcp-host=bert,192.168.0.70,infinite
|
||||
|
||||
# Always give the host with client identifier 01:02:02:04
|
||||
# the IP address 192.168.0.60
|
||||
#dhcp-host=id:01:02:02:04,192.168.0.60
|
||||
|
||||
# Always give the host with client identifier "marjorie"
|
||||
# the IP address 192.168.0.60
|
||||
#dhcp-host=id:marjorie,192.168.0.60
|
||||
|
||||
# Enable the address given for "judge" in /etc/hosts
|
||||
# to be given to a machine presenting the name "judge" when
|
||||
# it asks for a DHCP lease.
|
||||
#dhcp-host=judge
|
||||
|
||||
# Never offer DHCP service to a machine whose Ethernet
|
||||
# address is 11:22:33:44:55:66
|
||||
#dhcp-host=11:22:33:44:55:66,ignore
|
||||
|
||||
# Ignore any client-id presented by the machine with Ethernet
|
||||
# address 11:22:33:44:55:66. This is useful to prevent a machine
|
||||
# being treated differently when running under different OS's or
|
||||
# between PXE boot and OS boot.
|
||||
#dhcp-host=11:22:33:44:55:66,id:*
|
||||
|
||||
# Send extra options which are tagged as "red" to
|
||||
# the machine with Ethernet address 11:22:33:44:55:66
|
||||
#dhcp-host=11:22:33:44:55:66,set:red
|
||||
|
||||
# Send extra options which are tagged as "red" to
|
||||
# any machine with Ethernet address starting 11:22:33:
|
||||
#dhcp-host=11:22:33:*:*:*,set:red
|
||||
|
||||
# Give a fixed IPv6 address and name to client with
|
||||
# DUID 00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2
|
||||
# Note the MAC addresses CANNOT be used to identify DHCPv6 clients.
|
||||
# Note also the they [] around the IPv6 address are obilgatory.
|
||||
#dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5]
|
||||
|
||||
# Ignore any clients which are not specified in dhcp-host lines
|
||||
# or /etc/ethers. Equivalent to ISC "deny unknown-clients".
|
||||
# This relies on the special "known" tag which is set when
|
||||
# a host is matched.
|
||||
#dhcp-ignore=tag:!known
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine whose
|
||||
# DHCP vendorclass string includes the substring "Linux"
|
||||
#dhcp-vendorclass=set:red,Linux
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine one
|
||||
# of whose DHCP userclass strings includes the substring "accounts"
|
||||
#dhcp-userclass=set:red,accounts
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine whose
|
||||
# MAC address matches the pattern.
|
||||
#dhcp-mac=set:red,00:60:8C:*:*:*
|
||||
|
||||
# If this line is uncommented, dnsmasq will read /etc/ethers and act
|
||||
# on the ethernet-address/IP pairs found there just as if they had
|
||||
# been given as --dhcp-host options. Useful if you keep
|
||||
# MAC-address/host mappings there for other purposes.
|
||||
#read-ethers
|
||||
|
||||
# Send options to hosts which ask for a DHCP lease.
|
||||
# See RFC 2132 for details of available options.
|
||||
# Common options can be given to dnsmasq by name:
|
||||
# run "dnsmasq --help dhcp" to get a list.
|
||||
# Note that all the common settings, such as netmask and
|
||||
# broadcast address, DNS server and default route, are given
|
||||
# sane defaults by dnsmasq. You very likely will not need
|
||||
# any dhcp-options. If you use Windows clients and Samba, there
|
||||
# are some options which are recommended, they are detailed at the
|
||||
# end of this section.
|
||||
|
||||
# Override the default route supplied by dnsmasq, which assumes the
|
||||
# router is the same machine as the one running dnsmasq.
|
||||
#dhcp-option=3,1.2.3.4
|
||||
|
||||
# Do the same thing, but using the option name
|
||||
#dhcp-option=option:router,1.2.3.4
|
||||
|
||||
# Override the default route supplied by dnsmasq and send no default
|
||||
# route at all. Note that this only works for the options sent by
|
||||
# default (1, 3, 6, 12, 28) the same line will send a zero-length option
|
||||
# for all other option numbers.
|
||||
#dhcp-option=3
|
||||
|
||||
# Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5
|
||||
#dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5
|
||||
|
||||
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
||||
#dhcp-option=option6:dns-server,[1234::77],[1234::88]
|
||||
|
||||
# Send DHCPv6 option for namservers as the machine running
|
||||
# dnsmasq and another.
|
||||
#dhcp-option=option6:dns-server,[::],[1234::88]
|
||||
|
||||
# Ask client to poll for option changes every six hours. (RFC4242)
|
||||
#dhcp-option=option6:information-refresh-time,6h
|
||||
|
||||
# Set the NTP time server address to be the same machine as
|
||||
# is running dnsmasq
|
||||
#dhcp-option=42,0.0.0.0
|
||||
|
||||
# Set the NIS domain name to "welly"
|
||||
#dhcp-option=40,welly
|
||||
|
||||
# Set the default time-to-live to 50
|
||||
#dhcp-option=23,50
|
||||
|
||||
# Set the "all subnets are local" flag
|
||||
#dhcp-option=27,1
|
||||
|
||||
# Send the etherboot magic flag and then etherboot options (a string).
|
||||
#dhcp-option=128,e4:45:74:68:00:00
|
||||
#dhcp-option=129,NIC=eepro100
|
||||
|
||||
# Specify an option which will only be sent to the "red" network
|
||||
# (see dhcp-range for the declaration of the "red" network)
|
||||
# Note that the tag: part must precede the option: part.
|
||||
#dhcp-option = tag:red, option:ntp-server, 192.168.1.1
|
||||
|
||||
# The following DHCP options set up dnsmasq in the same way as is specified
|
||||
# for the ISC dhcpcd in
|
||||
# http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt
|
||||
# adapted for a typical dnsmasq installation where the host running
|
||||
# dnsmasq is also the host running samba.
|
||||
# you may want to uncomment some or all of them if you use
|
||||
# Windows clients and Samba.
|
||||
#dhcp-option=19,0 # option ip-forwarding off
|
||||
#dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
|
||||
#dhcp-option=45,0.0.0.0 # netbios datagram distribution server
|
||||
#dhcp-option=46,8 # netbios node type
|
||||
|
||||
# Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave.
|
||||
#dhcp-option=252,"\n"
|
||||
|
||||
# Send RFC-3397 DNS domain search DHCP option. WARNING: Your DHCP client
|
||||
# probably doesn't support this......
|
||||
#dhcp-option=option:domain-search,eng.apple.com,marketing.apple.com
|
||||
|
||||
# Send RFC-3442 classless static routes (note the netmask encoding)
|
||||
#dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
|
||||
|
||||
# Send vendor-class specific options encapsulated in DHCP option 43.
|
||||
# The meaning of the options is defined by the vendor-class so
|
||||
# options are sent only when the client supplied vendor class
|
||||
# matches the class given here. (A substring match is OK, so "MSFT"
|
||||
# matches "MSFT" and "MSFT 5.0"). This example sets the
|
||||
# mtftp address to 0.0.0.0 for PXEClients.
|
||||
#dhcp-option=vendor:PXEClient,1,0.0.0.0
|
||||
|
||||
# Send microsoft-specific option to tell windows to release the DHCP lease
|
||||
# when it shuts down. Note the "i" flag, to tell dnsmasq to send the
|
||||
# value as a four-byte integer - that's what microsoft wants. See
|
||||
# http://technet2.microsoft.com/WindowsServer/en/library/a70f1bb7-d2d4-49f0-96d6-4b7414ecfaae1033.mspx?mfr=true
|
||||
#dhcp-option=vendor:MSFT,2,1i
|
||||
|
||||
# Send the Encapsulated-vendor-class ID needed by some configurations of
|
||||
# Etherboot to allow is to recognise the DHCP server.
|
||||
#dhcp-option=vendor:Etherboot,60,"Etherboot"
|
||||
|
||||
# Send options to PXELinux. Note that we need to send the options even
|
||||
# though they don't appear in the parameter request list, so we need
|
||||
# to use dhcp-option-force here.
|
||||
# See http://syslinux.zytor.com/pxe.php#special for details.
|
||||
# Magic number - needed before anything else is recognised
|
||||
#dhcp-option-force=208,f1:00:74:7e
|
||||
# Configuration file name
|
||||
#dhcp-option-force=209,configs/common
|
||||
# Path prefix
|
||||
#dhcp-option-force=210,/tftpboot/pxelinux/files/
|
||||
# Reboot time. (Note 'i' to send 32-bit value)
|
||||
#dhcp-option-force=211,30i
|
||||
|
||||
# Set the boot filename for netboot/PXE. You will only need
|
||||
# this is you want to boot machines over the network and you will need
|
||||
# a TFTP server; either dnsmasq's built in TFTP server or an
|
||||
# external one. (See below for how to enable the TFTP server.)
|
||||
#dhcp-boot=pxelinux.0
|
||||
|
||||
# The same as above, but use custom tftp-server instead machine running dnsmasq
|
||||
#dhcp-boot=pxelinux,server.name,192.168.1.100
|
||||
|
||||
# Boot for Etherboot gPXE. The idea is to send two different
|
||||
# filenames, the first loads gPXE, and the second tells gPXE what to
|
||||
# load. The dhcp-match sets the gpxe tag for requests from gPXE.
|
||||
#dhcp-match=set:gpxe,175 # gPXE sends a 175 option.
|
||||
#dhcp-boot=tag:!gpxe,undionly.kpxe
|
||||
#dhcp-boot=mybootimage
|
||||
|
||||
# Encapsulated options for Etherboot gPXE. All the options are
|
||||
# encapsulated within option 175
|
||||
#dhcp-option=encap:175, 1, 5b # priority code
|
||||
#dhcp-option=encap:175, 176, 1b # no-proxydhcp
|
||||
#dhcp-option=encap:175, 177, string # bus-id
|
||||
#dhcp-option=encap:175, 189, 1b # BIOS drive code
|
||||
#dhcp-option=encap:175, 190, user # iSCSI username
|
||||
#dhcp-option=encap:175, 191, pass # iSCSI password
|
||||
|
||||
# Test for the architecture of a netboot client. PXE clients are
|
||||
# supposed to send their architecture as option 93. (See RFC 4578)
|
||||
#dhcp-match=peecees, option:client-arch, 0 #x86-32
|
||||
#dhcp-match=itanics, option:client-arch, 2 #IA64
|
||||
#dhcp-match=hammers, option:client-arch, 6 #x86-64
|
||||
#dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
|
||||
|
||||
# Do real PXE, rather than just booting a single file, this is an
|
||||
# alternative to dhcp-boot.
|
||||
#pxe-prompt="What system shall I netboot?"
|
||||
# or with timeout before first available action is taken:
|
||||
#pxe-prompt="Press F8 for menu.", 60
|
||||
|
||||
# Available boot services. for PXE.
|
||||
#pxe-service=x86PC, "Boot from local disk"
|
||||
|
||||
# Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
|
||||
#pxe-service=x86PC, "Install Linux", pxelinux
|
||||
|
||||
# Loads <tftp-root>/pxelinux.0 from TFTP server at 1.2.3.4.
|
||||
# Beware this fails on old PXE ROMS.
|
||||
#pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4
|
||||
|
||||
# Use bootserver on network, found my multicast or broadcast.
|
||||
#pxe-service=x86PC, "Install windows from RIS server", 1
|
||||
|
||||
# Use bootserver at a known IP address.
|
||||
#pxe-service=x86PC, "Install windows from RIS server", 1, 1.2.3.4
|
||||
|
||||
# If you have multicast-FTP available,
|
||||
# information for that can be passed in a similar way using options 1
|
||||
# to 5. See page 19 of
|
||||
# http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
|
||||
|
||||
|
||||
# Enable dnsmasq's built-in TFTP server
|
||||
#enable-tftp
|
||||
|
||||
# Set the root directory for files available via FTP.
|
||||
#tftp-root=/var/ftpd
|
||||
|
||||
# Make the TFTP server more secure: with this set, only files owned by
|
||||
# the user dnsmasq is running as will be send over the net.
|
||||
#tftp-secure
|
||||
|
||||
# This option stops dnsmasq from negotiating a larger blocksize for TFTP
|
||||
# transfers. It will slow things down, but may rescue some broken TFTP
|
||||
# clients.
|
||||
#tftp-no-blocksize
|
||||
|
||||
# Set the boot file name only when the "red" tag is set.
|
||||
#dhcp-boot=tag:red,pxelinux.red-net
|
||||
|
||||
# An example of dhcp-boot with an external TFTP server: the name and IP
|
||||
# address of the server are given after the filename.
|
||||
# Can fail with old PXE ROMS. Overridden by --pxe-service.
|
||||
#dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3
|
||||
|
||||
# If there are multiple external tftp servers having a same name
|
||||
# (using /etc/hosts) then that name can be specified as the
|
||||
# tftp_servername (the third option to dhcp-boot) and in that
|
||||
# case dnsmasq resolves this name and returns the resultant IP
|
||||
# addresses in round robin fasion. This facility can be used to
|
||||
# load balance the tftp load among a set of servers.
|
||||
#dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name
|
||||
|
||||
# Set the limit on DHCP leases, the default is 150
|
||||
#dhcp-lease-max=150
|
||||
|
||||
# The DHCP server needs somewhere on disk to keep its lease database.
|
||||
# This defaults to a sane location, but if you want to change it, use
|
||||
# the line below.
|
||||
#dhcp-leasefile=/var/lib/misc/dnsmasq.leases
|
||||
|
||||
# Set the DHCP server to authoritative mode. In this mode it will barge in
|
||||
# and take over the lease for any client which broadcasts on the network,
|
||||
# whether it has a record of the lease or not. This avoids long timeouts
|
||||
# when a machine wakes up on a new network. DO NOT enable this if there's
|
||||
# the slightest chance that you might end up accidentally configuring a DHCP
|
||||
# server for your campus/company accidentally. The ISC server uses
|
||||
# the same option, and this URL provides more information:
|
||||
# http://www.isc.org/files/auth.html
|
||||
#dhcp-authoritative
|
||||
|
||||
# Run an executable when a DHCP lease is created or destroyed.
|
||||
# The arguments sent to the script are "add" or "del",
|
||||
# then the MAC address, the IP address and finally the hostname
|
||||
# if there is one.
|
||||
#dhcp-script=/bin/echo
|
||||
|
||||
# Set the cachesize here.
|
||||
#cache-size=150
|
||||
|
||||
# If you want to disable negative caching, uncomment this.
|
||||
#no-negcache
|
||||
|
||||
# Normally responses which come from /etc/hosts and the DHCP lease
|
||||
# file have Time-To-Live set as zero, which conventionally means
|
||||
# do not cache further. If you are happy to trade lower load on the
|
||||
# server for potentially stale date, you can set a time-to-live (in
|
||||
# seconds) here.
|
||||
#local-ttl=
|
||||
|
||||
# If you want dnsmasq to detect attempts by Verisign to send queries
|
||||
# to unregistered .com and .net hosts to its sitefinder service and
|
||||
# have dnsmasq instead return the correct NXDOMAIN response, uncomment
|
||||
# this line. You can add similar lines to do the same for other
|
||||
# registries which have implemented wildcard A records.
|
||||
#bogus-nxdomain=64.94.110.11
|
||||
|
||||
# If you want to fix up DNS results from upstream servers, use the
|
||||
# alias option. This only works for IPv4.
|
||||
# This alias makes a result of 1.2.3.4 appear as 5.6.7.8
|
||||
#alias=1.2.3.4,5.6.7.8
|
||||
# and this maps 1.2.3.x to 5.6.7.x
|
||||
#alias=1.2.3.0,5.6.7.0,255.255.255.0
|
||||
# and this maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40
|
||||
#alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0
|
||||
|
||||
# Change these lines if you want dnsmasq to serve MX records.
|
||||
|
||||
# Return an MX record named "maildomain.com" with target
|
||||
# servermachine.com and preference 50
|
||||
#mx-host=maildomain.com,servermachine.com,50
|
||||
|
||||
# Set the default target for MX records created using the localmx option.
|
||||
#mx-target=servermachine.com
|
||||
|
||||
# Return an MX record pointing to the mx-target for all local
|
||||
# machines.
|
||||
#localmx
|
||||
|
||||
# Return an MX record pointing to itself for all local machines.
|
||||
#selfmx
|
||||
|
||||
# Change the following lines if you want dnsmasq to serve SRV
|
||||
# records. These are useful if you want to serve ldap requests for
|
||||
# Active Directory and other windows-originated DNS requests.
|
||||
# See RFC 2782.
|
||||
# You may add multiple srv-host lines.
|
||||
# The fields are <name>,<target>,<port>,<priority>,<weight>
|
||||
# If the domain part if missing from the name (so that is just has the
|
||||
# service and protocol sections) then the domain given by the domain=
|
||||
# config option is used. (Note that expand-hosts does not need to be
|
||||
# set for this to work.)
|
||||
|
||||
# A SRV record sending LDAP for the example.com domain to
|
||||
# ldapserver.example.com port 389
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
|
||||
|
||||
# A SRV record sending LDAP for the example.com domain to
|
||||
# ldapserver.example.com port 389 (using domain=)
|
||||
#domain=example.com
|
||||
#srv-host=_ldap._tcp,ldapserver.example.com,389
|
||||
|
||||
# Two SRV records for LDAP, each with different priorities
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
|
||||
|
||||
# A SRV record indicating that there is no LDAP server for the domain
|
||||
# example.com
|
||||
#srv-host=_ldap._tcp.example.com
|
||||
|
||||
# The following line shows how to make dnsmasq serve an arbitrary PTR
|
||||
# record. This is useful for DNS-SD. (Note that the
|
||||
# domain-name expansion done for SRV records _does_not
|
||||
# occur for PTR records.)
|
||||
#ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services"
|
||||
|
||||
# Change the following lines to enable dnsmasq to serve TXT records.
|
||||
# These are used for things like SPF and zeroconf. (Note that the
|
||||
# domain-name expansion done for SRV records _does_not
|
||||
# occur for TXT records.)
|
||||
|
||||
#Example SPF.
|
||||
#txt-record=example.com,"v=spf1 a -all"
|
||||
|
||||
#Example zeroconf
|
||||
#txt-record=_http._tcp.example.com,name=value,paper=A4
|
||||
|
||||
# Provide an alias for a "local" DNS name. Note that this _only_ works
|
||||
# for targets which are names from DHCP or /etc/hosts. Give host
|
||||
# "bert" another name, bertrand
|
||||
#cname=bertand,bert
|
||||
|
||||
# For debugging purposes, log each DNS query as it passes through
|
||||
# dnsmasq.
|
||||
#log-queries
|
||||
|
||||
# Log lots of extra information about DHCP transactions.
|
||||
#log-dhcp
|
||||
|
||||
# Include another lot of configuration options.
|
||||
#conf-file=/etc/dnsmasq.more.conf
|
||||
#conf-dir=/etc/dnsmasq.d
|
||||
|
||||
# Include all the files in a directory except those ending in .bak
|
||||
#conf-dir=/etc/dnsmasq.d,.bak
|
||||
|
||||
# Include all files in a directory which end in .conf
|
||||
#conf-dir=/etc/dnsmasq.d/*.conf
|
@@ -1 +1,12 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Swap file config
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
CONF_SWAPSIZE=500
|
||||
|
1
advanced/index.js
Normal file
1
advanced/index.js
Normal file
@@ -0,0 +1 @@
|
||||
var x = "Pi-hole: A black hole for Internet advertisements."
|
@@ -1,3 +1,14 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# lighttpd config for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
server.modules = (
|
||||
"mod_access",
|
||||
"mod_accesslog",
|
||||
@@ -42,4 +53,6 @@ $HTTP["url"] =~ "^/admin/" {
|
||||
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||
# Create a response header for debugging using curl -I
|
||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||
# rewrite only js requests
|
||||
url.rewrite = ("(.*).js" => "pihole/index.js")
|
||||
}
|
||||
|
@@ -1,15 +1,26 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Updates ad sources every week
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||
# Download any updates from the ad lists
|
||||
59 1 * * 7 root /usr/local/bin/gravity.sh
|
||||
# Download any updates from the adlists
|
||||
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
||||
|
||||
# Pi-hole: Update the Web interface shortly after gravity runs
|
||||
# This should also update the version number if it is changed in the dashboard repo
|
||||
30 2 * * 7 root /usr/local/bin/updateDashboard.sh
|
||||
30 2 * * 7 root /usr/local/bin/pihole updateDashboard
|
||||
|
||||
# Pi-hole: Parse the log file before it is flushed and save the stats to a database
|
||||
# This will be used for a historical view of your Pi-hole's performance
|
||||
#50 23 * * * root /usr/local/bin/dailyLog.sh
|
||||
#50 23 * * * root /usr/local/bin/dailyLog.sh # note: this is outdated
|
||||
|
||||
# Pi-hole: Flush the log daily at 11:58 so it doesn't get out of control
|
||||
# Stats will be viewable in the Web interface thanks to the cron job above
|
||||
58 23 * * * root /usr/local/bin/piholeLogFlush.sh
|
||||
58 23 * * * root /usr/local/bin/pihole flush
|
||||
|
File diff suppressed because it is too large
Load Diff
171
automated install/uninstall.sh
Normal file → Executable file
171
automated install/uninstall.sh
Normal file → Executable file
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Completely uninstalls the Pi-hole
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# This file is part of Pi-hole.
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Completely uninstalls Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -10,62 +12,135 @@
|
||||
|
||||
# Must be root to uninstall
|
||||
if [[ $EUID -eq 0 ]];then
|
||||
echo "You are root."
|
||||
echo "::: You are root."
|
||||
else
|
||||
echo "sudo will be used for the install."
|
||||
echo "::: Sudo will be used for the uninstall."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the unnstall cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "Please install sudo or run this as root."
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
spinner()
|
||||
{
|
||||
local pid=$1
|
||||
local delay=0.50
|
||||
local spinstr='/-\|'
|
||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=$temp${spinstr%"$temp"}
|
||||
sleep $delay
|
||||
printf "\b\b\b\b\b\b"
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
}
|
||||
|
||||
function removeAndPurge {
|
||||
# Purge dependencies
|
||||
echo ":::"
|
||||
# Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common
|
||||
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common git curl unzip wget )
|
||||
for i in "${dependencies[@]}"; do
|
||||
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
||||
while true; do
|
||||
read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "done!\n"; break;;
|
||||
[Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;;
|
||||
* ) printf "::: You must answer yes or no!\n";;
|
||||
esac
|
||||
done
|
||||
else
|
||||
printf ":::\tPackage %s not installed... Not removing.\n" "$i"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove dependency config files
|
||||
echo "::: Removing dnsmasq config files..."
|
||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||
|
||||
# Take care of any additional package cleaning
|
||||
printf "::: Auto removing remaining dependencies..."
|
||||
$SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "done!\n";
|
||||
printf "::: Auto cleaning remaining dependencies..."
|
||||
$SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "done!\n";
|
||||
|
||||
# Call removeNoPurge to remove PiHole specific files
|
||||
removeNoPurge
|
||||
}
|
||||
|
||||
function removeNoPurge {
|
||||
echo ":::"
|
||||
# Only web directories/files that are created by pihole should be removed.
|
||||
echo "::: Removing the Pi-hole Web server files..."
|
||||
$SUDO rm -rf /var/www/html/admin &> /dev/null
|
||||
$SUDO rm -rf /var/www/html/pihole &> /dev/null
|
||||
$SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null
|
||||
|
||||
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||
if [ -d "/var/www/html" ]; then
|
||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||
$SUDO rm -rf /var/www/html &> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
# to guarantee no additional changes were made to /etc/crontab after
|
||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||
# preserved.
|
||||
if [[ -f /etc/crontab.orig ]]; then
|
||||
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
||||
$SUDO mv /etc/crontab /etc/crontab.pihole
|
||||
$SUDO mv /etc/crontab.orig /etc/crontab
|
||||
$SUDO service cron restart
|
||||
fi
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
if [[ -f /etc/cron.d/pihole ]];then
|
||||
echo "::: Removing cron.d/pihole..."
|
||||
$SUDO rm /etc/cron.d/pihole &> /dev/null
|
||||
fi
|
||||
|
||||
echo "::: Removing config files and scripts..."
|
||||
if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
||||
$SUDO rm -rf /etc/lighttpd/ &> /dev/null
|
||||
else
|
||||
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
||||
$SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
$SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null
|
||||
$SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||
$SUDO rm -rf /var/log/*pihole* &> /dev/null
|
||||
$SUDO rm -rf /etc/pihole/ &> /dev/null
|
||||
$SUDO rm -rf /etc/.pihole/ &> /dev/null
|
||||
$SUDO rm -rf /opt/pihole/ &> /dev/null
|
||||
$SUDO rm /usr/local/bin/pihole &> /dev/null
|
||||
$SUDO rm /etc/bash_completion.d/pihole
|
||||
|
||||
echo ":::"
|
||||
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
||||
printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L https://install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n"
|
||||
printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!\n"
|
||||
}
|
||||
|
||||
######### SCRIPT ###########
|
||||
$SUDO apt-get -y remove --purge dnsutils bc toilet
|
||||
$SUDO apt-get -y remove --purge dnsmasq
|
||||
$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
||||
echo "::: Preparing to remove packages, be sure that each may be safely removed depending on your operating system."
|
||||
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
||||
while true; do
|
||||
read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]* ) removeAndPurge; break;;
|
||||
|
||||
[Nn]* ) removeNoPurge; break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Only web directories/files that are created by pihole should be removed.
|
||||
echo "Removing the Pi-hole Web server files..."
|
||||
$SUDO rm -rf /var/www/html/admin
|
||||
$SUDO rm -rf /var/www/html/pihole
|
||||
$SUDO rm /var/www/html/index.lighttpd.orig
|
||||
|
||||
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||
$SUDO rm -rf /var/www/html
|
||||
fi
|
||||
|
||||
echo "Removing dnsmasq config files..."
|
||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
# to guarantee no additional changes were made to /etc/crontab after
|
||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||
# preserved.
|
||||
if [[ -f /etc/crontab.orig ]]; then
|
||||
echo "Initial Pi-hole cron detected. Restoring the default system cron..."
|
||||
$SUDO mv /etc/crontab /etc/crontab.pihole
|
||||
$SUDO mv /etc/crontab.orig /etc/crontab
|
||||
$SUDO service cron restart
|
||||
fi
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
if [[ -f /etc/cron.d/pihole ]];then
|
||||
echo "Removing cron.d/pihole..."
|
||||
$SUDO rm /etc/cron.d/pihole
|
||||
fi
|
||||
|
||||
echo "Removing config files and scripts..."
|
||||
$SUDO rm /etc/dnsmasq.conf
|
||||
$SUDO rm -rf /etc/lighttpd/
|
||||
$SUDO rm /var/log/pihole.log
|
||||
$SUDO rm /usr/local/bin/gravity.sh
|
||||
$SUDO rm /usr/local/bin/chronometer.sh
|
||||
$SUDO rm /usr/local/bin/whitelist.sh
|
||||
$SUDO rm /usr/local/bin/piholeLogFlush.sh
|
||||
$SUDO rm -rf /etc/pihole/
|
||||
|
@@ -1,3 +1,14 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Lighttpd config file for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
server.modules = (
|
||||
"mod_access",
|
||||
"mod_alias",
|
||||
@@ -27,6 +38,6 @@ include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
|
||||
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
|
||||
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
||||
|
||||
$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com" {
|
||||
$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com|ads-e-darwin.hulu.com" {
|
||||
url.redirect = ( ".*" => "http://192.168.1.101:8200/MediaItems/19.mov")
|
||||
}
|
||||
|
@@ -1,6 +1,17 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# MiniDLNA config file for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
media_dir=V,/var/lib/minidlna/videos/
|
||||
port=8200
|
||||
friendly_name=pihole
|
||||
serial=12345678
|
||||
model_number=1
|
||||
inotify=yes
|
||||
inotify=yes
|
||||
|
233
gravity.sh
233
gravity.sh
@@ -10,8 +10,30 @@
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Run this script as root or under sudo
|
||||
echo ":::"
|
||||
if [[ $EUID -eq 0 ]];then
|
||||
echo "::: You are root."
|
||||
else
|
||||
echo "::: sudo will be used."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the install cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
piholeIPfile=/tmp/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
adListFile=/etc/pihole/adlists.list
|
||||
adListDefault=/etc/pihole/adlists.default
|
||||
whitelistScript=/opt/pihole/whitelist.sh
|
||||
blacklistScript=/opt/pihole/blacklist.sh
|
||||
|
||||
if [[ -f $piholeIPfile ]];then
|
||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||
piholeIP=$(cat $piholeIPfile)
|
||||
@@ -19,7 +41,7 @@ if [[ -f $piholeIPfile ]];then
|
||||
else
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
fi
|
||||
|
||||
@@ -28,53 +50,87 @@ if [[ -f $piholeIPv6file ]];then
|
||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||
fi
|
||||
|
||||
# Ad-list sources--one per line in single quotes
|
||||
# The mahakala source is commented out due to many users having issues with it blocking legitimate domains.
|
||||
# Uncomment at your own risk
|
||||
sources=('https://adaway.org/hosts.txt'
|
||||
'http://adblock.gjtech.net/?format=unix-hosts'
|
||||
#'http://adblock.mahakala.is/'
|
||||
'http://hosts-file.net/ad_servers.txt'
|
||||
'http://www.malwaredomainlist.com/hostslist/hosts.txt'
|
||||
'http://pgl.yoyo.org/adservers/serverlist.php?'
|
||||
'http://someonewhocares.org/hosts/hosts'
|
||||
'http://winhelp2002.mvps.org/hosts.txt')
|
||||
|
||||
# Variables for various stages of downloading and formatting the list
|
||||
## Nate 3/26/2016 - Commented unused variables
|
||||
basename=pihole
|
||||
piholeDir=/etc/$basename
|
||||
adList=$piholeDir/gravity.list
|
||||
blacklist=$piholeDir/blacklist.txt
|
||||
whitelist=$piholeDir/whitelist.txt
|
||||
latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||
#blacklist=$piholeDir/blacklist.txt
|
||||
#whitelist=$piholeDir/whitelist.txt
|
||||
#latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||
justDomainsExtension=domains
|
||||
matterandlight=$basename.0.matterandlight.txt
|
||||
supernova=$basename.1.supernova.txt
|
||||
eventHorizon=$basename.2.eventHorizon.txt
|
||||
accretionDisc=$basename.3.accretionDisc.txt
|
||||
eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||
#eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||
|
||||
# After setting defaults, check if there's local overrides
|
||||
if [[ -r $piholeDir/pihole.conf ]];then
|
||||
echo "** Local calibration requested..."
|
||||
echo "::: Local calibration requested..."
|
||||
. $piholeDir/pihole.conf
|
||||
fi
|
||||
|
||||
spinner() {
|
||||
local pid=$1
|
||||
local delay=0.50
|
||||
local spinstr='/-|'
|
||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=$temp${spinstr%"$temp"}
|
||||
sleep $delay
|
||||
printf "\b\b\b\b\b\b"
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
}
|
||||
|
||||
###########################
|
||||
# collapse - begin formation of pihole
|
||||
function gravity_collapse() {
|
||||
echo "** Neutrino emissions detected..."
|
||||
echo "::: Neutrino emissions detected..."
|
||||
echo ":::"
|
||||
#Decide if we're using a custom ad block list, or defaults.
|
||||
if [ -f $adListFile ]; then
|
||||
#custom file found, use this instead of default
|
||||
echo -n "::: Custom adList file detected. Reading..."
|
||||
sources=()
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||
echo "" > /dev/null
|
||||
else
|
||||
sources+=($line)
|
||||
fi
|
||||
done < $adListFile
|
||||
echo " done!"
|
||||
else
|
||||
#no custom file found, use defaults!
|
||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||
sources=()
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||
echo "" > /dev/null
|
||||
else
|
||||
sources+=($line)
|
||||
fi
|
||||
done < $adListDefault
|
||||
echo " done!"
|
||||
fi
|
||||
|
||||
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
||||
if [[ -d $piholeDir ]];then
|
||||
# Temporary hack to allow non-root access to pihole directory
|
||||
# Will update later, needed for existing installs, new installs should
|
||||
# create this directory as non-root
|
||||
sudo chmod 777 $piholeDir
|
||||
find "$piholeDir" -type f -exec sudo chmod 666 {} \;
|
||||
$SUDO chmod 777 $piholeDir
|
||||
echo ":::"
|
||||
echo "::: Existing pihole directory found"
|
||||
else
|
||||
echo "** Creating pihole directory..."
|
||||
echo "::: Creating pihole directory..."
|
||||
mkdir $piholeDir
|
||||
$SUDO chmod 777 $piholeDir
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -86,11 +142,11 @@ function gravity_patternCheck() {
|
||||
# Some of the blocklists are copyright, they need to be downloaded
|
||||
# and stored as is. They can be processed for content after they
|
||||
# have been saved.
|
||||
cp $patternBuffer $saveLocation
|
||||
echo "List updated, transport successful..."
|
||||
cp "$patternBuffer" "$saveLocation"
|
||||
echo " List updated, transport successful!"
|
||||
else
|
||||
# curl didn't download any host files, probably because of the date check
|
||||
echo "No changes detected, transport skipped..."
|
||||
echo " No changes detected, transport skipped!"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -111,15 +167,14 @@ function gravity_transport() {
|
||||
# Silently curl url
|
||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
||||
# Check for list updates
|
||||
gravity_patternCheck $patternBuffer
|
||||
|
||||
gravity_patternCheck "$patternBuffer"
|
||||
# Cleanup
|
||||
rm -f $patternBuffer
|
||||
rm -f "$patternBuffer"
|
||||
}
|
||||
|
||||
# spinup - main gravity function
|
||||
function gravity_spinup() {
|
||||
|
||||
echo ":::"
|
||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
||||
do
|
||||
@@ -133,80 +188,96 @@ function gravity_spinup() {
|
||||
|
||||
agent="Mozilla/10.0"
|
||||
|
||||
echo -n " Getting $domain list: "
|
||||
echo -n "::: Getting $domain list..."
|
||||
|
||||
# Use a case statement to download lists that need special cURL commands
|
||||
# to complete properly and reset the user agent when required
|
||||
case "$domain" in
|
||||
"adblock.mahakala.is")
|
||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
||||
cmd_ext="-e http://forum.xda-developers.com/"
|
||||
;;
|
||||
"adblock.mahakala.is")
|
||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
||||
cmd_ext="-e http://forum.xda-developers.com/"
|
||||
;;
|
||||
|
||||
"pgl.yoyo.org")
|
||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||
;;
|
||||
"pgl.yoyo.org")
|
||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||
;;
|
||||
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
esac
|
||||
gravity_transport $url $cmd_ext $agent
|
||||
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||
done
|
||||
}
|
||||
|
||||
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
||||
function gravity_Schwarzchild() {
|
||||
|
||||
echo "::: "
|
||||
# Find all active domains and compile them into one file and remove CRs
|
||||
echo "** Aggregating list of domains..."
|
||||
truncate -s 0 $piholeDir/$matterandlight
|
||||
echo -n "::: Aggregating list of domains..."
|
||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
||||
for i in "${activeDomains[@]}"
|
||||
do
|
||||
cat $i |tr -d '\r' >> $piholeDir/$matterandlight
|
||||
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
|
||||
done
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
|
||||
function gravity_Blacklist(){
|
||||
# Append blacklist entries if they exist
|
||||
blacklist.sh -f -nr -q
|
||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
||||
|
||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||
echo " $numBlacklisted domain${plural} blacklisted!"
|
||||
}
|
||||
|
||||
|
||||
function gravity_Whitelist() {
|
||||
echo ":::"
|
||||
# Prevent our sources from being pulled into the hole
|
||||
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
||||
echo "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
||||
|
||||
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
||||
|
||||
urls=()
|
||||
for url in ${sources[@]}
|
||||
for url in "${sources[@]}"
|
||||
do
|
||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
||||
urls=("${urls[@]}" $tmp)
|
||||
done
|
||||
|
||||
whitelist.sh -f -nr -q ${urls[@]}
|
||||
echo " done!"
|
||||
|
||||
|
||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $!
|
||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
||||
}
|
||||
|
||||
function gravity_unique() {
|
||||
# Sort and remove duplicates
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
|
||||
echo -n "::: Removing duplicate domains...."
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $!
|
||||
echo " done!"
|
||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
||||
echo "** $numberOf unique domains trapped in the event horizon."
|
||||
echo "::: $numberOf unique domains trapped in the event horizon."
|
||||
}
|
||||
|
||||
function gravity_hostFormat() {
|
||||
# Format domain list as "192.168.x.x domain.com"
|
||||
echo "** Formatting domains into a HOSTS file..."
|
||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' > $piholeDir/$accretionDisc
|
||||
else
|
||||
# Otherwise, just create gravity.list as normal using IPv4
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' > $piholeDir/$accretionDisc
|
||||
fi
|
||||
echo "::: Formatting domains into a HOSTS file..."
|
||||
hostname=$(</etc/hostname)
|
||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||
echo -e "$piholeIP $hostname\n$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
else
|
||||
# Otherwise, just create gravity.list as normal using IPv4
|
||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
fi
|
||||
|
||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||
cp $piholeDir/$accretionDisc $adList
|
||||
}
|
||||
@@ -217,44 +288,60 @@ function gravity_blackbody() {
|
||||
for file in $piholeDir/*.$justDomainsExtension
|
||||
do
|
||||
# If list is in active array then leave it (noop) else rm the list
|
||||
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
||||
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||
:
|
||||
else
|
||||
rm -f $file
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function gravity_advanced() {
|
||||
|
||||
|
||||
# Remove comments and print only the domain name
|
||||
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
||||
# This helps with that and makes it easier to read
|
||||
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
|
||||
echo -n "::: Formatting list of domains to remove comments...."
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $!
|
||||
echo " done!"
|
||||
|
||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
||||
echo "** $numberOf domains being pulled in by gravity..."
|
||||
echo "::: $numberOf domains being pulled in by gravity..."
|
||||
|
||||
gravity_unique
|
||||
}
|
||||
|
||||
function gravity_reload() {
|
||||
#Clear no longer needed files...
|
||||
echo ":::"
|
||||
echo -n "::: Cleaning up un-needed files..."
|
||||
$SUDO rm $piholeDir/pihole.*.txt
|
||||
echo " done!"
|
||||
|
||||
# Reload hosts file
|
||||
echo "** Refresh lists in dnsmasq..."
|
||||
echo ":::"
|
||||
echo -n "::: Refresh lists in dnsmasq..."
|
||||
|
||||
#ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list!
|
||||
#First escape forward slashes in the path:
|
||||
adList=${adList//\//\\\/}
|
||||
#Now replace the line in dnsmasq file
|
||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
sudo kill -HUP $dnsmasqPid
|
||||
$SUDO kill -HUP "$dnsmasqPid" & spinner $!
|
||||
else
|
||||
# service not running, start it up
|
||||
sudo service dnsmasq start
|
||||
$SUDO service dnsmasq start & spinner $!
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
|
||||
$SUDO cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
||||
gravity_collapse
|
||||
gravity_spinup
|
||||
gravity_Schwarzchild
|
||||
|
114
pihole
Executable file
114
pihole
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Controller for all pihole scripts and functions.
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Must be root to use this tool
|
||||
if [[ ! $EUID -eq 0 ]];then
|
||||
#echo "::: You are root."
|
||||
#else
|
||||
#echo "::: Sudo will be used for this tool."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
function whitelistFunc {
|
||||
shift
|
||||
$SUDO /opt/pihole/whitelist.sh "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function blacklistFunc {
|
||||
shift
|
||||
$SUDO /opt/pihole/blacklist.sh "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function debugFunc {
|
||||
$SUDO /opt/pihole/piholeDebug.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function flushFunc {
|
||||
$SUDO /opt/pihole/piholeLogFlush.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function updateDashboardFunc {
|
||||
$SUDO /opt/pihole/updateDashboard.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function updateGravityFunc {
|
||||
$SUDO /opt/pihole/gravity.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function setupLCDFunction {
|
||||
$SUDO /opt/pihole/setupLCD.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function chronometerFunc {
|
||||
shift
|
||||
$SUDO /opt/pihole/chronometer.sh "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
function uninstallFunc {
|
||||
$SUDO /opt/pihole/uninstall.sh
|
||||
exit 1
|
||||
}
|
||||
|
||||
function helpFunc {
|
||||
echo "::: Control all PiHole specific functions!"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole.sh [options]"
|
||||
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -w, whitelist Whitelist domains"
|
||||
echo "::: -b, blacklist Blacklist domains"
|
||||
echo "::: -d, debug Start a debugging session if having trouble"
|
||||
echo "::: -f, flush Flush the pihole.log file"
|
||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
||||
echo "::: -h, help Show this help dialog"
|
||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
# Handle redirecting to specific functions based on arguments
|
||||
case "$1" in
|
||||
"-w" | "whitelist" ) whitelistFunc "$@";;
|
||||
"-b" | "blacklist" ) blacklistFunc "$@";;
|
||||
"-d" | "debug" ) debugFunc;;
|
||||
"-f" | "flush" ) flushFunc;;
|
||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||
"-h" | "help" ) helpFunc;;
|
||||
"uninstall" ) uninstallFunc;;
|
||||
* ) helpFunc;;
|
||||
esac
|
Reference in New Issue
Block a user