Compare commits
450 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec6ecf0d60 | ||
|
|
fdb0e31a78 | ||
|
|
01a9534729 | ||
|
|
921278c5ea | ||
|
|
d938f73207 | ||
|
|
344e63c2dc | ||
|
|
681144b2a3 | ||
|
|
e4295f5d3c | ||
|
|
77135ca3c7 | ||
|
|
29b548f07c | ||
|
|
cb33ef77f7 | ||
|
|
49ded54306 | ||
|
|
6c0a8a4337 | ||
|
|
e9a0ddf798 | ||
|
|
d217626318 | ||
|
|
4f5fcc2a37 | ||
|
|
ed94f4b1df | ||
|
|
a57b097afc | ||
|
|
eb42b894c4 | ||
|
|
af666e2209 | ||
|
|
2f2e746e56 | ||
|
|
b3e7619048 | ||
|
|
0121136498 | ||
|
|
7eb43a0b47 | ||
|
|
c0430a2248 | ||
|
|
6796b8bdad | ||
|
|
475d016029 | ||
|
|
201304e678 | ||
|
|
fdb104348c | ||
|
|
f54828352d | ||
|
|
cc157def63 | ||
|
|
8fc83655ab | ||
|
|
9fb549293a | ||
|
|
e4cc5b5b70 | ||
|
|
6f0b659b38 | ||
|
|
652bdf1518 | ||
|
|
f6ac0d73b4 | ||
|
|
ae47be0ce9 | ||
|
|
491c37eafe | ||
|
|
3ade7a8b0e | ||
|
|
3c7738b6d0 | ||
|
|
037318e2ff | ||
|
|
a9a499939e | ||
|
|
7e5bcd2ec3 | ||
|
|
f49ca48a22 | ||
|
|
9cb4e8bde8 | ||
|
|
95edb49bb8 | ||
|
|
fb69bf551e | ||
|
|
fe8d0f8ea8 | ||
|
|
acc5fa2a95 | ||
|
|
f2e33f8581 | ||
|
|
4748cdc2c9 | ||
|
|
2bc364023a | ||
|
|
3070f61e20 | ||
|
|
57df56dc62 | ||
|
|
e11ef5a7f0 | ||
|
|
6a17a3eeec | ||
|
|
66ff9a24c6 | ||
|
|
a3b3a7a34d | ||
|
|
c04b3559d0 | ||
|
|
e642b41b5b | ||
|
|
ba6881d685 | ||
|
|
20d8c9053b | ||
|
|
0749e4ed70 | ||
|
|
b0cc69ff80 | ||
|
|
02c4669e95 | ||
|
|
8550b76e23 | ||
|
|
fdf27e3d24 | ||
|
|
069023fca2 | ||
|
|
1fd6648db1 | ||
|
|
7a08c8b694 | ||
|
|
60aad3f19b | ||
|
|
51dcc2bc0f | ||
|
|
941525d1e0 | ||
|
|
5fb6c5b012 | ||
|
|
3affa73257 | ||
|
|
c647e27e15 | ||
|
|
f696ed48b3 | ||
|
|
73645f299a | ||
|
|
6aeb5f1172 | ||
|
|
ce8f07750f | ||
|
|
a32ad0dbf2 | ||
|
|
61ff12e8d4 | ||
|
|
02b0e96db8 | ||
|
|
e942440bb7 | ||
|
|
a27f1f17de | ||
|
|
e106ff0fef | ||
|
|
6f068e0b9c | ||
|
|
ada531c88a | ||
|
|
f0a2248c81 | ||
|
|
11f2524b9b | ||
|
|
b011e5f838 | ||
|
|
f45eb84d6b | ||
|
|
412c0a172d | ||
|
|
c1d8496b93 | ||
|
|
4657959790 | ||
|
|
2b0ba281a4 | ||
|
|
325a41c598 | ||
|
|
9b8efe1b27 | ||
|
|
024b741552 | ||
|
|
4e95f4678f | ||
|
|
a86b982591 | ||
|
|
ec8da00485 | ||
|
|
bcfe130d51 | ||
|
|
0e143f7275 | ||
|
|
7670b4e380 | ||
|
|
636a9123b8 | ||
|
|
caaee40889 | ||
|
|
1f130b6550 | ||
|
|
2ce47f49b1 | ||
|
|
0250e03b86 | ||
|
|
ce110aab90 | ||
|
|
fd92752f52 | ||
|
|
3c4a305976 | ||
|
|
791e5bbd55 | ||
|
|
46df6e7dd3 | ||
|
|
9ccf9d57a8 | ||
|
|
fa89bd830a | ||
|
|
3ba05d0274 | ||
|
|
0d9a8d70bf | ||
|
|
5c79184d3b | ||
|
|
3d619d9ccc | ||
|
|
afdf3ae7a1 | ||
|
|
943f7c06b5 | ||
|
|
27a9642090 | ||
|
|
d0b6ff2d08 | ||
|
|
97737ee9e3 | ||
|
|
5e27ccc37c | ||
|
|
682113892a | ||
|
|
376eb81181 | ||
|
|
4fc40d96d9 | ||
|
|
e6634531c7 | ||
|
|
66724826f5 | ||
|
|
04e375a523 | ||
|
|
65638973ea | ||
|
|
9c26bdd676 | ||
|
|
b31931c907 | ||
|
|
c74af2c21f | ||
|
|
c160b2e54b | ||
|
|
c4234f4542 | ||
|
|
62fa9c0f6e | ||
|
|
8198f06073 | ||
|
|
6f2117d786 | ||
|
|
b3ec3b487c | ||
|
|
d67957d015 | ||
|
|
94f131a0b7 | ||
|
|
7af0029175 | ||
|
|
f4228b04f8 | ||
|
|
ffaf243160 | ||
|
|
29d48bbd9a | ||
|
|
37dda79db2 | ||
|
|
063e3e85e1 | ||
|
|
42afaa9f66 | ||
|
|
366fcf76f6 | ||
|
|
72e8ec7d93 | ||
|
|
13a479a9f6 | ||
|
|
1194e48bd8 | ||
|
|
1e0666d1ef | ||
|
|
1c53ad6876 | ||
|
|
dc2a537f6b | ||
|
|
a5d3022e9f | ||
|
|
4541da1f17 | ||
|
|
a16cd9aef7 | ||
|
|
6cf446032f | ||
|
|
3fda2d9ac3 | ||
|
|
c03268707a | ||
|
|
7829e907c9 | ||
|
|
b5529e5138 | ||
|
|
d601afcebc | ||
|
|
892a90bf51 | ||
|
|
d52a8f08ed | ||
|
|
b7e27bf6b4 | ||
|
|
9ee96d6176 | ||
|
|
c0e1772e21 | ||
|
|
62dc160c65 | ||
|
|
f03303e5aa | ||
|
|
7bc2844b9d | ||
|
|
ba283755be | ||
|
|
2209beff8a | ||
|
|
00cc480bc1 | ||
|
|
d7de5b2afa | ||
|
|
221b72439b | ||
|
|
08e6f60941 | ||
|
|
10066209e7 | ||
|
|
08e95ed606 | ||
|
|
a5ad48aa18 | ||
|
|
81fdfcba22 | ||
|
|
24de6d6fc9 | ||
|
|
aec6fcd00b | ||
|
|
619082dbed | ||
|
|
09cdf5081c | ||
|
|
d7abbbfac4 | ||
|
|
c714196647 | ||
|
|
b702c1d9a8 | ||
|
|
56ac04c48e | ||
|
|
b58519b974 | ||
|
|
ad574f5e90 | ||
|
|
4941a657bf | ||
|
|
3d4bff9414 | ||
|
|
2d03616c10 | ||
|
|
fcb9ba08a8 | ||
|
|
77f4126f9b | ||
|
|
4c890ab202 | ||
|
|
d10e9b1b6e | ||
|
|
a6bee76581 | ||
|
|
2f4f5a6ad2 | ||
|
|
3853997295 | ||
|
|
76899c9ac5 | ||
|
|
99a5b3a98a | ||
|
|
219aff9a93 | ||
|
|
b6e1b3bff0 | ||
|
|
1ce888e828 | ||
|
|
1c10a801dc | ||
|
|
48fa83c9ac | ||
|
|
31ea3a2757 | ||
|
|
05e0003555 | ||
|
|
be79281418 | ||
|
|
01f53f6d6c | ||
|
|
107e0404de | ||
|
|
ab99e80333 | ||
|
|
3154a378a6 | ||
|
|
8e04f1c03e | ||
|
|
c0aadeab3d | ||
|
|
6c87698f1a | ||
|
|
db2e9f8bf3 | ||
|
|
9a4c5cef86 | ||
|
|
bdfc86f850 | ||
|
|
70dadfba28 | ||
|
|
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 | ||
|
|
3142992c57 | ||
|
|
ecd46f8560 | ||
|
|
73bfbba5f7 | ||
|
|
eee0ccef8c | ||
|
|
29c593b8b0 | ||
|
|
71fd32b1f4 | ||
|
|
fcf3b4e4e2 |
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
|
||||||
14
.pullapprove.yml
Normal file
14
.pullapprove.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
approve_by_comment: true
|
||||||
|
approve_regex: '^(Approved|:shipit:|:\+1:)'
|
||||||
|
reject_regex: '^(Rejected|:-1:)'
|
||||||
|
reset_on_push: true
|
||||||
|
author_approval: required
|
||||||
|
reviewers:
|
||||||
|
members:
|
||||||
|
- brantje
|
||||||
|
- dschaper
|
||||||
|
- jacobsalmela
|
||||||
|
- Mcat12
|
||||||
|
- PromoFaux
|
||||||
|
name: pullapprove
|
||||||
|
required: 3
|
||||||
148
README.md
148
README.md
@@ -1,95 +1,125 @@
|
|||||||
# Automated Install
|
[](https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||||
##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet adapter)
|
|
||||||
|
|
||||||
1. Install Raspbian
|
# Automated Install
|
||||||
2. Run the command below
|
|
||||||
|
|
||||||
### ```curl -L install.pi-hole.net | bash```
|
Designed For Raspberry Pi A+, B, B+, 2, 3B, and Zero (with an Ethernet/Wi-Fi adapter)
|
||||||
|
Works on most Debian and CentOS/RHEL based distributions!
|
||||||
|
|
||||||
#### Alternative Semi-Automated install ####
|
1. Install Raspbian
|
||||||
```
|
2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!)
|
||||||
wget -O basic-install.sh install.pi-hole.net
|
|
||||||
|
## `curl -L https://install.pi-hole.net | bash`
|
||||||
|
|
||||||
|
### Alternative Semi-Automated install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O basic-install.sh https://install.pi-hole.net
|
||||||
chmod +x basic-install.sh
|
chmod +x basic-install.sh
|
||||||
./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/).
|
If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer
|
||||||
|
|
||||||
## Pi-hole Is Free, But Powered By Your Donations
|
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/).
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
|
|
||||||
|
## How To Install Pi-hole
|
||||||
|
|
||||||
|
[](https://www.youtube.com/watch?v=TzFLJqUeirA)
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
## How Does It Work?
|
|
||||||
**Watch the 60-second video below to get a quick overview**
|
**Watch the 60-second video below to get a quick overview**
|
||||||
|
|
||||||
[](https://vimeo.com/135965232)
|
[](https://youtu.be/9Eti3xibiho)
|
||||||
|
|
||||||
## Pi-hole Projects
|
## Pi-hole Is Free, But Powered By Your Donations
|
||||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
|
||||||
- [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/)
|
|
||||||
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
|
|
||||||
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
|
|
||||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
|
||||||
|
|
||||||
## Coverage
|
Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the monthly fee.
|
||||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
|
||||||
- [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/)
|
|
||||||
- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)!
|
|
||||||
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
|
|
||||||
- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
|
|
||||||
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
|
||||||
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
|
||||||
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
|
||||||
|
|
||||||
## Partnering With Optimal.com
|
-  : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY)
|
||||||
|
-  : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole)
|
||||||
|
-  : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL
|
||||||
|
|
||||||
Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/).
|
## Get Help Or Connect With Us On The Web
|
||||||
|
|
||||||
|
- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
||||||
|
- [/r/pihole](https://www.reddit.com/r/pihole/)
|
||||||
|
- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
|
||||||
|
- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization)
|
||||||
|
- [FAQs](https://pi-hole.net/help/)
|
||||||
|
- [](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
## Technical Details
|
## Technical Details
|
||||||
|
|
||||||
The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads.
|
The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads.
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
## Gravity
|
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)).
|
||||||
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/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
|
||||||
|
|
||||||
## Web Interface
|
## 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`
|
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:
|
||||||
|
|
||||||
### API
|
`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Whitelist and blacklist
|
||||||
|
|
||||||
|
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 
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
||||||
```JSON
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
"domains_being_blocked": "136708",
|
"domains_being_blocked": "136708",
|
||||||
"dns_queries_today": "18108",
|
"dns_queries_today": "18108",
|
||||||
"ads_blocked_today": "14648",
|
"ads_blocked_today": "14648",
|
||||||
"ads_percentage_today": "80.89"
|
"ads_percentage_today": "80.89"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
The same output can be acheived on the CLI by running `chronometer.sh -j`
|
|
||||||
|
|
||||||

|
The same output can be achieved on the CLI by running `chronometer.sh -j`
|
||||||
|
|
||||||
## Real-time Statistics
|
## 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/pi-hole/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
|
## Pi-hole Projects
|
||||||
- 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)
|
- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||||
|
- [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/)
|
||||||
|
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
|
||||||
|
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
|
||||||
|
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
||||||
|
- [Windows Tray Stat Application](https://github.com/goldbattle/copernicus)
|
||||||
|
|
||||||
|
## Coverage
|
||||||
|
|
||||||
|
- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI)
|
||||||
|
- [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/)
|
||||||
|
- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)!
|
||||||
|
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
|
||||||
|
- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
|
||||||
|
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
||||||
|
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
||||||
|
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
||||||
|
|
||||||
## Other Operating Systems
|
## 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.
|
||||||
|
|||||||
@@ -1,17 +1,57 @@
|
|||||||
https://adaway.org/hosts.txt
|
## Pi-hole ad-list default sources. Updated 22/05/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://adblock.gjtech.net/?format=unix-hosts
|
||||||
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
|
|
||||||
http://mirror1.malwaredomains.com/files/justdomains
|
http://mirror1.malwaredomains.com/files/justdomains
|
||||||
http://securemecca.com/Downloads/hosts.txt
|
|
||||||
https://hosts.neocities.org/
|
|
||||||
http://sysctl.org/cameleon/hosts
|
http://sysctl.org/cameleon/hosts
|
||||||
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
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_tracking.txt
|
||||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||||
http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
|
||||||
|
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||||
|
https://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/data/hosts/win10/spy.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
|
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
|
||||||
|
|
||||||
|
# List of known C&C malware servers (see https://github.com/pi-hole/pi-hole/issues/528)
|
||||||
|
https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt
|
||||||
|
|
||||||
|
# Untested Lists:
|
||||||
|
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||||
|
#https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt
|
||||||
|
#http://malwaredomains.lehigh.edu/files/domains.txt
|
||||||
|
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
|
||||||
|
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
||||||
|
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
||||||
|
# Combination of serveral host files on the internet (warning some facebook domains are also blocked but you can go to facebook.com). See https://github.com/mat1th/Dns-add-block for more information.
|
||||||
|
#https://raw.githubusercontent.com/mat1th/Dns-add-block/master/hosts
|
||||||
|
|||||||
211
advanced/Scripts/blacklist.sh
Normal file → Executable file
211
advanced/Scripts/blacklist.sh
Normal file → Executable file
@@ -10,69 +10,102 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
#rootcheck
|
||||||
|
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 [ -x "$(command -v sudo)" ];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
function helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||||
|
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"
|
||||||
|
echo "::: -l, --list Display your blacklisted domains"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
echo "Immediately blacklists one or more domains in the hosts file"
|
helpFunc
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
blacklist=/etc/pihole/blacklist.txt
|
basename=pihole
|
||||||
adList=/etc/pihole/gravity.list
|
piholeDir=/etc/${basename}
|
||||||
|
adList=${piholeDir}/gravity.list
|
||||||
|
blacklist=${piholeDir}/blacklist.txt
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
versbose=true
|
verbose=true
|
||||||
|
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPfile=/tmp/piholeIP
|
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
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
|
if [[ -f ${piholeIPfile} ]];then
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
# 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
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
piholeIP=$(cat ${piholeIPfile})
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
#rm $piholeIPfile
|
||||||
|
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}')
|
||||||
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
fi
|
||||||
|
|
||||||
modifyHost=false
|
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 [[ -f ${piholeIPv6file} ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function HandleOther(){
|
||||||
function HandleOther(){
|
|
||||||
#check validity of domain
|
#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
|
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
|
else
|
||||||
domList=("${domList[@]}" $validDomain)
|
domList=("${domList[@]}" ${validDomain})
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function PopBlacklistFile(){
|
function PopBlacklistFile(){
|
||||||
#check blacklist file exists, and if not, create it
|
#check blacklist file exists, and if not, create it
|
||||||
if [[ ! -f $blacklist ]];then
|
if [[ ! -f ${blacklist} ]];then
|
||||||
touch $blacklist
|
touch ${blacklist}
|
||||||
fi
|
fi
|
||||||
for dom in "${domList[@]}"
|
for dom in "${domList[@]}"; do
|
||||||
do
|
if "$addmode"; then
|
||||||
if $addmode; then
|
AddDomain "$dom"
|
||||||
AddDomain $dom
|
|
||||||
else
|
else
|
||||||
RemoveDomain $dom
|
RemoveDomain "$dom"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -80,72 +113,69 @@ function PopBlacklistFile(){
|
|||||||
function AddDomain(){
|
function AddDomain(){
|
||||||
#| sed 's/\./\\./g'
|
#| sed 's/\./\\./g'
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" $blacklist || bool=true
|
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||||
if $bool; then
|
if ${bool}; then
|
||||||
#domain not found in the blacklist file, add it!
|
#domain not found in the blacklist file, add it!
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo -n "::: Adding $1 to blacklist file..."
|
echo -n "::: Adding $1 to blacklist file..."
|
||||||
fi
|
fi
|
||||||
echo $1 >> $blacklist
|
echo "$1" >> ${blacklist}
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 already exists in blacklist.txt! No need to add"
|
echo "::: $1 already exists in $blacklist! No need to add"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveDomain(){
|
function RemoveDomain(){
|
||||||
|
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" $blacklist || bool=true
|
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||||
if $bool; then
|
if ${bool}; then
|
||||||
#Domain is not in the blacklist file, no need to Remove
|
#Domain is not in the blacklist file, no need to Remove
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 is NOT blacklisted! No need to remove"
|
echo "::: $1 is NOT blacklisted! No need to remove"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#Domain is in the blacklist file, add to a temporary array
|
#Domain is in the blacklist file, add to a temporary array
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: Un-blacklisting $dom..."
|
echo "::: Un-blacklisting $dom..."
|
||||||
fi
|
fi
|
||||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModifyHostFile(){
|
function ModifyHostFile(){
|
||||||
if $addmode; then
|
if ${addmode}; then
|
||||||
#add domains to the hosts file
|
#add domains to the hosts file
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r ${blacklist} ]];then
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
numberOf=$(cat ${blacklist} | sed '/^\s*$/d' | wc -l)
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n ${piholeIPv6} ]];then
|
||||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
cat ${blacklist} | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${adList}
|
||||||
else
|
else
|
||||||
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
cat ${blacklist} | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>${adList}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
for dom in "${domToRemoveList[@]}"
|
for dom in "${domToRemoveList[@]}"
|
||||||
do
|
do
|
||||||
#we need to remove the domains from the blacklist file and the host file
|
#we need to remove the domains from the blacklist file and the host file
|
||||||
echo "::: $dom"
|
echo "::: $dom"
|
||||||
echo -n "::: removing from HOSTS file..."
|
echo -n "::: removing from HOSTS 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 /[^.]'{}'(?!.)/;' ${adList}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo -n "::: removing from blackist.txt..."
|
echo -n "::: removing from blackist.txt..."
|
||||||
echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${blacklist}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Reload() {
|
function Reload() {
|
||||||
@@ -155,40 +185,53 @@ function Reload() {
|
|||||||
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP $dnsmasqPid
|
${SUDO} killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
${SUDO} service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DisplayBlist() {
|
||||||
|
verbose=false
|
||||||
|
echo -e " Displaying Gravity Affected Domains \n"
|
||||||
|
count=1
|
||||||
|
while IFS= read -r AD
|
||||||
|
do
|
||||||
|
echo "${count}: $AD"
|
||||||
|
count=$((count+1))
|
||||||
|
done < "$blacklist"
|
||||||
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"-nr"| "--noreload" ) reload=false;;
|
"-nr"| "--noreload" ) reload=false;;
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) verbose=false;;
|
||||||
* ) HandleOther $var;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"-l" | "--list" ) DisplayBlist;;
|
||||||
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
PopBlacklistFile
|
PopBlacklistFile
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
if ${modifyHost} || ${force}; then
|
||||||
ModifyHostFile
|
ModifyHostFile
|
||||||
else
|
else
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: No changes need to be made"
|
echo "::: No changes need to be made"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $reload; then
|
if ${reload}; then
|
||||||
Reload
|
Reload
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function CalcBlockedDomains(){
|
|||||||
CheckIPv6
|
CheckIPv6
|
||||||
if [ -e "$gravity" ]; then
|
if [ -e "$gravity" ]; then
|
||||||
#Are we IPV6 or IPV4?
|
#Are we IPV6 or IPV4?
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n ${piholeIPv6} ]];then
|
||||||
#We are IPV6
|
#We are IPV6
|
||||||
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
|
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
|
||||||
else
|
else
|
||||||
@@ -43,7 +43,7 @@ function CalcQueriesToday(){
|
|||||||
|
|
||||||
function CalcblockedToday(){
|
function CalcblockedToday(){
|
||||||
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
||||||
blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
blockedToday="Err."
|
blockedToday="Err."
|
||||||
fi
|
fi
|
||||||
@@ -63,7 +63,7 @@ function CalcPercentBlockedToday(){
|
|||||||
|
|
||||||
function CheckIPv6(){
|
function CheckIPv6(){
|
||||||
piholeIPv6file="/etc/pihole/.useIPv6"
|
piholeIPv6file="/etc/pihole/.useIPv6"
|
||||||
if [[ -f $piholeIPv6file ]];then
|
if [[ -f ${piholeIPv6file} ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
@@ -73,9 +73,9 @@ function outputJSON(){
|
|||||||
CalcQueriesToday
|
CalcQueriesToday
|
||||||
CalcblockedToday
|
CalcblockedToday
|
||||||
CalcPercentBlockedToday
|
CalcPercentBlockedToday
|
||||||
|
|
||||||
CalcBlockedDomains
|
CalcBlockedDomains
|
||||||
|
|
||||||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,47 +84,53 @@ function normalChrono(){
|
|||||||
do
|
do
|
||||||
clear
|
clear
|
||||||
# Displays a colorful Pi-hole logo
|
# Displays a colorful Pi-hole logo
|
||||||
toilet -f small -F gay Pi-hole
|
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||||
|
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||||
|
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||||
|
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||||
|
echo ""
|
||||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||||
echo ""
|
echo ""
|
||||||
uptime | cut -d' ' -f11-
|
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 "-------------------------------"
|
echo "-------------------------------"
|
||||||
# Uncomment to continually read the log file and display the current domain being blocked
|
# 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;}'
|
#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
|
#uncomment next 4 lines to use original query count calculation
|
||||||
#today=$(date "+%b %e")
|
#today=$(date "+%b %e")
|
||||||
#todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l)
|
#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)
|
#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)
|
#todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l)
|
||||||
|
|
||||||
|
|
||||||
CalcQueriesToday
|
CalcQueriesToday
|
||||||
CalcblockedToday
|
CalcblockedToday
|
||||||
CalcPercentBlockedToday
|
CalcPercentBlockedToday
|
||||||
|
|
||||||
CalcBlockedDomains
|
CalcBlockedDomains
|
||||||
|
|
||||||
echo "Blocking: $blockedDomainsTotal"
|
echo "Blocking: $blockedDomainsTotal"
|
||||||
#below commented line does not add up to todaysQueryCount
|
#below commented line does not add up to todaysQueryCount
|
||||||
#echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6"
|
#echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6"
|
||||||
echo "Queries: $queriesToday" #same total calculation as dashboard
|
echo "Queries: $queriesToday" #same total calculation as dashboard
|
||||||
echo "Pi-holed: $blockedToday ($percentBlockedToday%)"
|
echo "Pi-holed: $blockedToday ($percentBlockedToday%)"
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayHelp(){
|
function displayHelp(){
|
||||||
echo "Displays stats about your piHole!"
|
echo "::: Displays stats about your piHole!"
|
||||||
echo " "
|
echo ":::"
|
||||||
echo "Usage: chronometer.sh [optional:-j]"
|
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||||
echo "Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
||||||
echo " "
|
echo ":::"
|
||||||
echo "Options:"
|
echo "::: Options:"
|
||||||
echo " -j, --json output stats as JSON formatted string"
|
echo "::: -j, --json output stats as JSON formatted string"
|
||||||
echo " -h, --help display this help text"
|
echo "::: -h, --help display this help text"
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +142,7 @@ for var in "$@"
|
|||||||
do
|
do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"-j" | "--json" ) outputJSON;;
|
"-j" | "--json" ) outputJSON;;
|
||||||
"-h" | "--help" ) displayHelp;;
|
"-h" | "--help" ) displayHelp;;
|
||||||
* ) exit 1;;
|
* ) exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
364
advanced/Scripts/piholeDebug.sh
Executable file
364
advanced/Scripts/piholeDebug.sh
Executable file
@@ -0,0 +1,364 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
|
||||||
|
######## 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"
|
||||||
|
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
|
||||||
|
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 [ -x "$(command -v 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 versionCheck {
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
echo "########## Versions Section ###########" >> ${DEBUG_LOG}
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||||
|
echo "Pi-hole Version: $TMP" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0)
|
||||||
|
echo "WebUI Version: $TMP" >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
}
|
||||||
|
|
||||||
|
function distroCheck {
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
echo "######## Distribution Section #########" >> ${DEBUG_LOG}
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
TMP=$(cat /etc/*release || echo "Failed to find release")
|
||||||
|
echo "Distribution Version: $TMP" >> ${DEBUG_LOG}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
function debugLighttpd {
|
||||||
|
echo "::: Writing lighttpd to debug log..."
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
if [ -e "$LIGHTTPDFILE" ]
|
||||||
|
then
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ -e "$LIGHTTPDERRFILE" ]
|
||||||
|
then
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
echo "######### lighttpd error.log ##########" >> ${DEBUG_LOG}
|
||||||
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
cat "$LIGHTTPDERRFILE" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "No lighttpd error.log file found!" >> ${DEBUG_LOG}
|
||||||
|
printf ":::\tNo lighttpd error.log file found\n"
|
||||||
|
fi
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
}
|
||||||
|
|
||||||
|
### 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}
|
||||||
|
|
||||||
|
versionCheck
|
||||||
|
distroCheck
|
||||||
|
compareWhitelist
|
||||||
|
compareBlacklist
|
||||||
|
testNslookup
|
||||||
|
checkProcesses
|
||||||
|
debugLighttpd
|
||||||
|
|
||||||
|
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
|
||||||
|
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 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 "\n::: Finishing 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!"
|
||||||
|
echo "::: The degug log can be uploaded to Termbin.com for easier sharing."
|
||||||
|
read -r -p "::: Would you like to upload the log? [y/N] " response
|
||||||
|
case ${response} in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "::: Log will NOT be uploaded to Termbin."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Check if termbin.com is reachable. When it's not, point to local log instead
|
||||||
|
if [ -n "$TERMBIN" ]
|
||||||
|
then
|
||||||
|
echo "::: Debug log can be found at : $TERMBIN"
|
||||||
|
else
|
||||||
|
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trap finalWork EXIT
|
||||||
|
|
||||||
|
### Method calls for additional logging ###
|
||||||
|
dumpPiHoleLog
|
||||||
@@ -10,4 +10,6 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||||
truncate -s 0 /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 [ -x "$(command -v 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'
|
||||||
4
advanced/Scripts/updateDashboard.sh
Normal file → Executable file
4
advanced/Scripts/updateDashboard.sh
Normal file → Executable file
@@ -55,7 +55,7 @@ is_repo() {
|
|||||||
# replaces it with the current master branch from github
|
# replaces it with the current master branch from github
|
||||||
make_repo() {
|
make_repo() {
|
||||||
# remove the non-repod interface and clone the interface
|
# remove the non-repod interface and clone the interface
|
||||||
rm -rf $WEB_INTERFACE_DIR
|
rm -rf ${WEB_INTERFACE_DIR}
|
||||||
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
|
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ make_repo() {
|
|||||||
update_repo() {
|
update_repo() {
|
||||||
# pull the latest commits
|
# pull the latest commits
|
||||||
cd "$WEB_INTERFACE_DIR"
|
cd "$WEB_INTERFACE_DIR"
|
||||||
git pull
|
git pull
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
20
advanced/Scripts/version.sh
Normal file
20
advanced/Scripts/version.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/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
|
||||||
|
# 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
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||||
|
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||||
|
|
||||||
|
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
|
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
|
|
||||||
|
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||||
|
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||||
@@ -10,68 +10,102 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
#rootcheck
|
||||||
|
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 [ -x "$(command -v sudo)" ];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
function helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole -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"
|
||||||
|
echo "::: -l, --list Display your whitelisted domains"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
echo "Immediately whitelists one or more domains in the hosts file"
|
helpFunc
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
whitelist=/etc/pihole/whitelist.txt
|
basename=pihole
|
||||||
adList=/etc/pihole/gravity.list
|
piholeDir=/etc/${basename}
|
||||||
|
adList=${piholeDir}/gravity.list
|
||||||
|
whitelist=${piholeDir}/whitelist.txt
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
versbose=true
|
verbose=true
|
||||||
|
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
piholeIPfile=/tmp/piholeIP
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
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
|
if [[ -f ${piholeIPfile} ]];then
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
# 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
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
piholeIP=$(cat ${piholeIPfile})
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
#rm $piholeIPfile
|
||||||
|
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}')
|
||||||
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
fi
|
||||||
|
|
||||||
modifyHost=false
|
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 [[ -f ${piholeIPv6file} ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function HandleOther(){
|
||||||
function HandleOther(){
|
|
||||||
#check validity of domain
|
#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
|
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
|
else
|
||||||
domList=("${domList[@]}" $validDomain)
|
domList=("${domList[@]}" ${validDomain})
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function PopWhitelistFile(){
|
function PopWhitelistFile(){
|
||||||
#check whitelist file exists, and if not, create it
|
#check whitelist file exists, and if not, create it
|
||||||
if [[ ! -f $whitelist ]];then
|
if [[ ! -f ${whitelist} ]];then
|
||||||
touch $whitelist
|
touch ${whitelist}
|
||||||
fi
|
fi
|
||||||
for dom in "${domList[@]}"
|
for dom in "${domList[@]}"
|
||||||
do
|
do
|
||||||
if $addmode; then
|
if ${addmode}; then
|
||||||
AddDomain $dom
|
AddDomain "$dom"
|
||||||
else
|
else
|
||||||
RemoveDomain $dom
|
RemoveDomain "$dom"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -79,83 +113,86 @@ function PopWhitelistFile(){
|
|||||||
function AddDomain(){
|
function AddDomain(){
|
||||||
#| sed 's/\./\\./g'
|
#| sed 's/\./\\./g'
|
||||||
bool=false
|
bool=false
|
||||||
|
|
||||||
grep -Ex -q "$1" $whitelist || bool=true
|
grep -Ex -q "$1" ${whitelist} || bool=true
|
||||||
if $bool; then
|
if ${bool}; then
|
||||||
#domain not found in the whitelist file, add it!
|
#domain not found in the whitelist file, add it!
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo -n "::: Adding $1 to whitelist.txt..."
|
echo -n "::: Adding $1 to $whitelist..."
|
||||||
fi
|
fi
|
||||||
echo $1 >> $whitelist
|
echo "$1" >> ${whitelist}
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 already exists in whitelist.txt, no need to add!"
|
echo "::: $1 already exists in $whitelist, no need to add!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveDomain(){
|
function RemoveDomain(){
|
||||||
|
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" $whitelist || bool=true
|
grep -Ex -q "$1" ${whitelist} || bool=true
|
||||||
if $bool; then
|
if ${bool}; then
|
||||||
#Domain is not in the whitelist file, no need to Remove
|
#Domain is not in the whitelist file, no need to Remove
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 is NOT whitelisted! No need to remove"
|
echo "::: $1 is NOT whitelisted! No need to remove"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file
|
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file
|
||||||
#if $versbose; then
|
#if $verbose; then
|
||||||
#echo "::: Un-whitelisting $dom..."
|
#echo "::: Un-whitelisting $dom..."
|
||||||
#fi
|
#fi
|
||||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModifyHostFile(){
|
function ModifyHostFile(){
|
||||||
if $addmode; then
|
if ${addmode}; then
|
||||||
#remove domains in from hosts file
|
#remove domains in from hosts file
|
||||||
if [[ -r $whitelist ]];then
|
if [[ -r ${whitelist} ]];then
|
||||||
# Remove whitelist entries
|
# Remove whitelist entries
|
||||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
numberOf=$(cat ${whitelist} | sed '/^\s*$/d' | wc -l)
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
||||||
awk -F':' '{print $1}' $whitelist | while read line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
|
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 line; do echo "$piholeIPv6 $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
|
echo "l" >> /etc/pihole/whitelist.tmp
|
||||||
grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp
|
grep -F -x -v -f ${piholeDir}/whitelist.tmp ${adList} > ${piholeDir}/gravity.tmp
|
||||||
rm /etc/pihole/gravity.list
|
rm ${adList}
|
||||||
mv /etc/pihole/gravity.tmp /etc/pihole/gravity.list
|
mv ${piholeDir}/gravity.tmp ${adList}
|
||||||
rm /etc/pihole/whitelist.tmp
|
rm ${piholeDir}/whitelist.tmp
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#we need to add the removed domains to the hosts file
|
#we need to add the removed domains to the hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Modifying HOSTS file to un-whitelist domains..."
|
echo "::: Modifying HOSTS file to un-whitelist domains..."
|
||||||
for rdom in "${domToRemoveList[@]}"
|
for rdom in "${domToRemoveList[@]}"
|
||||||
do
|
do
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if grep -q "$rdom" /etc/pihole/*.domains; then
|
||||||
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..."
|
echo "::: AdLists contain $rdom, re-adding block"
|
||||||
echo $rdom | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
if [[ -n ${piholeIPv6} ]];then
|
||||||
echo " done!"
|
echo -n "::: Restoring block for $rdom on IPv4 and IPv6..."
|
||||||
else
|
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"
|
echo " done!"
|
||||||
echo $rdom | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
else
|
||||||
echo " done!"
|
echo -n "::: Restoring block for $rdom on IPv4..."
|
||||||
fi
|
echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>${adList}
|
||||||
echo -n "::: Removing $rdom from whitelist.txt..."
|
echo " done!"
|
||||||
echo $rdom| sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
fi
|
||||||
echo " done!"
|
fi
|
||||||
done
|
echo -n "::: Removing $rdom from $whitelist..."
|
||||||
fi
|
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelist}
|
||||||
|
echo " done!"
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function Reload() {
|
function Reload() {
|
||||||
@@ -164,41 +201,54 @@ function Reload() {
|
|||||||
echo -n "::: Refresh lists in dnsmasq..."
|
echo -n "::: Refresh lists in dnsmasq..."
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP $dnsmasqPid
|
${SUDO} killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
${SUDO} service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DisplayWlist() {
|
||||||
|
verbose=false
|
||||||
|
echo -e " Displaying Gravity Resistant Domains \n"
|
||||||
|
count=1
|
||||||
|
while IFS= read -r RD
|
||||||
|
do
|
||||||
|
echo "${count}: $RD"
|
||||||
|
count=$((count+1))
|
||||||
|
done < "$whitelist"
|
||||||
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"-nr"| "--noreload" ) reload=false;;
|
"-nr"| "--noreload" ) reload=false;;
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) verbose=false;;
|
||||||
* ) HandleOther $var;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"-l" | "--list" ) DisplayWlist;;
|
||||||
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
PopWhitelistFile
|
PopWhitelistFile
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
if ${modifyHost} || ${force}; then
|
||||||
ModifyHostFile
|
ModifyHostFile
|
||||||
else
|
else
|
||||||
if $versbose; then
|
if ${verbose}; then
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: No changes need to be made"
|
echo "::: No changes need to be made"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $reload; then
|
if ${reload}; then
|
||||||
Reload
|
Reload
|
||||||
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'
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
# Replies which are not DNSSEC signed may be legitimate, because the domain
|
# Replies which are not DNSSEC signed may be legitimate, because the domain
|
||||||
# is unsigned, or may be forgeries. Setting this option tells dnsmasq to
|
# 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
|
# 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.
|
# 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
|
# The cost of setting this is that even queries in unsigned domains will need
|
||||||
# one or more extra DNS queries to verify.
|
# one or more extra DNS queries to verify.
|
||||||
#dnssec-check-unsigned
|
#dnssec-check-unsigned
|
||||||
@@ -183,11 +183,11 @@
|
|||||||
#dhcp-range=1234::2, 1234::500, 64, 12h
|
#dhcp-range=1234::2, 1234::500, 64, 12h
|
||||||
|
|
||||||
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
||||||
#dhcp-range=1234::, ra-only
|
#dhcp-range=1234::, ra-only
|
||||||
|
|
||||||
# Do Router Advertisements, BUT NOT DHCP for this subnet, also try and
|
# 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
|
# 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
|
# hosts. Use the DHCPv4 lease to derive the name, network segment and
|
||||||
# MAC address and assume that the host will also have an
|
# MAC address and assume that the host will also have an
|
||||||
# IPv6 address calculated using the SLAAC alogrithm.
|
# IPv6 address calculated using the SLAAC alogrithm.
|
||||||
#dhcp-range=1234::, ra-names
|
#dhcp-range=1234::, ra-names
|
||||||
@@ -210,9 +210,9 @@
|
|||||||
#dhcp-range=1234::, ra-stateless, ra-names
|
#dhcp-range=1234::, ra-stateless, ra-names
|
||||||
|
|
||||||
# Do router advertisements for all subnets where we're doing DHCPv6
|
# Do router advertisements for all subnets where we're doing DHCPv6
|
||||||
# Unless overriden by ra-stateless, ra-names, et al, the router
|
# Unless overriden by ra-stateless, ra-names, et al, the router
|
||||||
# advertisements will have the M and O bits set, so that the clients
|
# 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
|
# get addresses and configuration from DHCPv6, and the A bit reset, so the
|
||||||
# clients don't use SLAAC addresses.
|
# clients don't use SLAAC addresses.
|
||||||
#enable-ra
|
#enable-ra
|
||||||
|
|
||||||
@@ -278,11 +278,11 @@
|
|||||||
# any machine with Ethernet address starting 11:22:33:
|
# any machine with Ethernet address starting 11:22:33:
|
||||||
#dhcp-host=11:22:33:*:*:*,set:red
|
#dhcp-host=11:22:33:*:*:*,set:red
|
||||||
|
|
||||||
# Give a fixed IPv6 address and name to client with
|
# 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
|
# 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 the MAC addresses CANNOT be used to identify DHCPv6 clients.
|
||||||
# Note also the they [] around the IPv6 address are obilgatory.
|
# 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]
|
#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
|
# Ignore any clients which are not specified in dhcp-host lines
|
||||||
# or /etc/ethers. Equivalent to ISC "deny unknown-clients".
|
# or /etc/ethers. Equivalent to ISC "deny unknown-clients".
|
||||||
@@ -338,7 +338,7 @@
|
|||||||
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
||||||
#dhcp-option=option6:dns-server,[1234::77],[1234::88]
|
#dhcp-option=option6:dns-server,[1234::77],[1234::88]
|
||||||
|
|
||||||
# Send DHCPv6 option for namservers as the machine running
|
# Send DHCPv6 option for namservers as the machine running
|
||||||
# dnsmasq and another.
|
# dnsmasq and another.
|
||||||
#dhcp-option=option6:dns-server,[::],[1234::88]
|
#dhcp-option=option6:dns-server,[::],[1234::88]
|
||||||
|
|
||||||
@@ -645,4 +645,4 @@
|
|||||||
#conf-dir=/etc/dnsmasq.d,.bak
|
#conf-dir=/etc/dnsmasq.d,.bak
|
||||||
|
|
||||||
# Include all files in a directory which end in .conf
|
# Include all files in a directory which end in .conf
|
||||||
#conf-dir=/etc/dnsmasq.d/*.conf
|
#conf-dir=/etc/dnsmasq.d/*.conf
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<script>window.close();</script>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
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."
|
||||||
@@ -14,7 +14,7 @@ server.modules = (
|
|||||||
"mod_accesslog",
|
"mod_accesslog",
|
||||||
"mod_expire",
|
"mod_expire",
|
||||||
"mod_compress",
|
"mod_compress",
|
||||||
"mod_redirect",
|
"mod_redirect",
|
||||||
"mod_setenv",
|
"mod_setenv",
|
||||||
"mod_rewrite"
|
"mod_rewrite"
|
||||||
)
|
)
|
||||||
@@ -46,11 +46,16 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
|||||||
# If the URL starts with /admin, it is the Web interface
|
# If the URL starts with /admin, it is the Web interface
|
||||||
$HTTP["url"] =~ "^/admin/" {
|
$HTTP["url"] =~ "^/admin/" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
setenv.add-response-header = (
|
||||||
|
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||||
|
"X-Frame-Options" => "DENY"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the URL does not start with /admin, then it is a query for an ad domain
|
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||||
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||||
|
# rewrite only js requests
|
||||||
|
url.rewrite = ("(.*).js" => "pihole/index.js")
|
||||||
}
|
}
|
||||||
77
advanced/lighttpd.conf.fedora
Normal file
77
advanced/lighttpd.conf.fedora
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# 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_fastcgi",
|
||||||
|
"mod_accesslog",
|
||||||
|
"mod_expire",
|
||||||
|
"mod_compress",
|
||||||
|
"mod_redirect",
|
||||||
|
"mod_setenv",
|
||||||
|
"mod_rewrite"
|
||||||
|
)
|
||||||
|
|
||||||
|
server.document-root = "/var/www/html"
|
||||||
|
server.error-handler-404 = "pihole/index.html"
|
||||||
|
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
|
||||||
|
server.errorlog = "/var/log/lighttpd/error.log"
|
||||||
|
server.pid-file = "/var/run/lighttpd.pid"
|
||||||
|
server.username = "lighttpd"
|
||||||
|
server.groupname = "lighttpd"
|
||||||
|
server.port = 80
|
||||||
|
accesslog.filename = "/var/log/lighttpd/access.log"
|
||||||
|
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
||||||
|
|
||||||
|
|
||||||
|
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
|
||||||
|
url.access-deny = ( "~", ".inc" )
|
||||||
|
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
|
||||||
|
|
||||||
|
compress.cache-dir = "/var/cache/lighttpd/compress/"
|
||||||
|
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
|
||||||
|
|
||||||
|
mimetype.assign = ( ".png" => "image/png",
|
||||||
|
".jpg" => "image/jpeg",
|
||||||
|
".jpeg" => "image/jpeg",
|
||||||
|
".html" => "text/html",
|
||||||
|
".css" => "text/css; charset=utf-8",
|
||||||
|
".js" => "application/javascript",
|
||||||
|
".json" => "application/json",
|
||||||
|
".txt" => "text/plain" )
|
||||||
|
|
||||||
|
# default listening port for IPv6 falls back to the IPv4 port
|
||||||
|
#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"
|
||||||
|
|
||||||
|
fastcgi.server = ( ".php" =>
|
||||||
|
( "localhost" =>
|
||||||
|
(
|
||||||
|
"socket" => "/tmp/php-fastcgi.socket",
|
||||||
|
"bin-path" => "/usr/bin/php-cgi"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# If the URL starts with /admin, it is the Web interface
|
||||||
|
$HTTP["url"] =~ "^/admin/" {
|
||||||
|
# Create a response header for debugging using curl -I
|
||||||
|
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
||||||
|
}
|
||||||
|
|
||||||
|
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||||
|
$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")
|
||||||
|
}
|
||||||
@@ -10,17 +10,17 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||||
# Download any updates from the ad lists
|
# Download any updates from the adlists
|
||||||
59 1 * * 7 root /usr/local/bin/gravity.sh
|
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
||||||
|
|
||||||
# Pi-hole: Update the Web interface shortly after gravity runs
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
||||||
|
|||||||
12
advanced/pihole.sudo
Normal file
12
advanced/pihole.sudo
Normal file
@@ -0,0 +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
|
||||||
|
# Allows the WebUI to use Pi-hole commands
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
www-data ALL=NOPASSWD: /usr/local/bin/pihole
|
||||||
87
advanced/selinux/pihole.te
Normal file
87
advanced/selinux/pihole.te
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
module pihole 1.0;
|
||||||
|
|
||||||
|
require {
|
||||||
|
type var_log_t;
|
||||||
|
type unconfined_t;
|
||||||
|
type init_t;
|
||||||
|
type auditd_t;
|
||||||
|
type syslogd_t;
|
||||||
|
type NetworkManager_t;
|
||||||
|
type mdadm_t;
|
||||||
|
type tuned_t;
|
||||||
|
type avahi_t;
|
||||||
|
type irqbalance_t;
|
||||||
|
type system_dbusd_t;
|
||||||
|
type kernel_t;
|
||||||
|
type httpd_sys_script_t;
|
||||||
|
type systemd_logind_t;
|
||||||
|
type httpd_t;
|
||||||
|
type policykit_t;
|
||||||
|
type dnsmasq_t;
|
||||||
|
type udev_t;
|
||||||
|
type postfix_pickup_t;
|
||||||
|
type sshd_t;
|
||||||
|
type crond_t;
|
||||||
|
type getty_t;
|
||||||
|
type lvm_t;
|
||||||
|
type postfix_qmgr_t;
|
||||||
|
type postfix_master_t;
|
||||||
|
class dir { getattr search };
|
||||||
|
class file { read open setattr };
|
||||||
|
}
|
||||||
|
|
||||||
|
#============= dnsmasq_t ==============
|
||||||
|
allow dnsmasq_t var_log_t:file { open setattr };
|
||||||
|
|
||||||
|
#============= httpd_t ==============
|
||||||
|
allow httpd_t var_log_t:file { read open };
|
||||||
|
|
||||||
|
#============= httpd_sys_script_t (class: dir) ==============
|
||||||
|
allow httpd_sys_script_t NetworkManager_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t auditd_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t avahi_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t crond_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t dnsmasq_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t getty_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t httpd_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t init_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t irqbalance_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t kernel_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t lvm_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t mdadm_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t policykit_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t postfix_master_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t postfix_pickup_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t postfix_qmgr_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t sshd_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t syslogd_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t system_dbusd_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t systemd_logind_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t tuned_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t udev_t:dir { getattr search };
|
||||||
|
allow httpd_sys_script_t unconfined_t:dir { getattr search };
|
||||||
|
|
||||||
|
#============= httpd_sys_script_t (class: file) ==============
|
||||||
|
allow httpd_sys_script_t NetworkManager_t:file { read open };
|
||||||
|
allow httpd_sys_script_t auditd_t:file { read open };
|
||||||
|
allow httpd_sys_script_t avahi_t:file { read open };
|
||||||
|
allow httpd_sys_script_t crond_t:file { read open };
|
||||||
|
allow httpd_sys_script_t dnsmasq_t:file { read open };
|
||||||
|
allow httpd_sys_script_t getty_t:file { read open };
|
||||||
|
allow httpd_sys_script_t httpd_t:file { read open };
|
||||||
|
allow httpd_sys_script_t init_t:file { read open };
|
||||||
|
allow httpd_sys_script_t irqbalance_t:file { read open };
|
||||||
|
allow httpd_sys_script_t kernel_t:file { read open };
|
||||||
|
allow httpd_sys_script_t lvm_t:file { read open };
|
||||||
|
allow httpd_sys_script_t mdadm_t:file { read open };
|
||||||
|
allow httpd_sys_script_t policykit_t:file { read open };
|
||||||
|
allow httpd_sys_script_t postfix_master_t:file { read open };
|
||||||
|
allow httpd_sys_script_t postfix_pickup_t:file { read open };
|
||||||
|
allow httpd_sys_script_t postfix_qmgr_t:file { read open };
|
||||||
|
allow httpd_sys_script_t sshd_t:file { read open };
|
||||||
|
allow httpd_sys_script_t syslogd_t:file { read open };
|
||||||
|
allow httpd_sys_script_t system_dbusd_t:file { read open };
|
||||||
|
allow httpd_sys_script_t systemd_logind_t:file { read open };
|
||||||
|
allow httpd_sys_script_t tuned_t:file { read open };
|
||||||
|
allow httpd_sys_script_t udev_t:file { read open };
|
||||||
|
allow httpd_sys_script_t unconfined_t:file { read open };
|
||||||
File diff suppressed because it is too large
Load Diff
199
automated install/uninstall.sh
Normal file → Executable file
199
automated install/uninstall.sh
Normal file → Executable file
@@ -12,62 +12,165 @@
|
|||||||
|
|
||||||
# Must be root to uninstall
|
# Must be root to uninstall
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ $EUID -eq 0 ]];then
|
||||||
echo "You are root."
|
echo "::: You are root."
|
||||||
else
|
else
|
||||||
echo "sudo will be used for the install."
|
echo "::: Sudo will be used for the uninstall."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the unnstall cannot complete
|
# If it isn't, exit because the unnstall cannot complete
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [ -x "$(command -v sudo)" ];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Compatability
|
||||||
|
if [ -x "$(command -v rpm)" ];then
|
||||||
|
# Fedora Family
|
||||||
|
if [ -x "$(command -v dnf)" ];then
|
||||||
|
PKG_MANAGER="dnf"
|
||||||
|
else
|
||||||
|
PKG_MANAGER="yum"
|
||||||
|
fi
|
||||||
|
PKG_REMOVE="$PKG_MANAGER remove -y"
|
||||||
|
PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils )
|
||||||
|
package_check() {
|
||||||
|
rpm -qa | grep ^$1- > /dev/null
|
||||||
|
}
|
||||||
|
package_cleanup() {
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
|
}
|
||||||
|
elif [ -x "$(command -v apt-get)" ];then
|
||||||
|
# Debian Family
|
||||||
|
PKG_MANAGER="apt-get"
|
||||||
|
PKG_REMOVE="$PKG_MANAGER -y remove --purge"
|
||||||
|
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
|
||||||
|
package_check() {
|
||||||
|
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
||||||
|
}
|
||||||
|
package_cleanup() {
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoclean
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "OS distribution not supported"
|
||||||
|
exit
|
||||||
|
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 ":::"
|
||||||
|
for i in "${PIHOLE_DEPS[@]}"; do
|
||||||
|
package_check ${i} > /dev/null
|
||||||
|
if [ $? -eq 0 ]; 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} ${PKG_REMOVE} "$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 & cleaning remaining dependencies..."
|
||||||
|
package_cleanup &> /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..."
|
||||||
|
package_check ${i} > /dev/null
|
||||||
|
if [ $? -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 &> /dev/null
|
||||||
|
${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
|
||||||
|
|
||||||
|
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 ###########
|
######### SCRIPT ###########
|
||||||
$SUDO apt-get -y remove --purge dnsutils bc toilet
|
echo "::: Preparing to remove packages, be sure that each may be safely removed depending on your operating system."
|
||||||
$SUDO apt-get -y remove --purge dnsmasq
|
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
||||||
$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
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
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
case ${yn} in
|
||||||
echo "Removing the Pi-hole Web server files..."
|
[Yy]* ) removeAndPurge; break;;
|
||||||
$SUDO rm -rf /var/www/html/admin
|
|
||||||
$SUDO rm -rf /var/www/html/pihole
|
[Nn]* ) removeNoPurge; break;;
|
||||||
$SUDO rm /var/www/html/index.lighttpd.orig
|
esac
|
||||||
|
done
|
||||||
# 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/
|
|
||||||
|
|||||||
294
gravity.sh
294
gravity.sh
@@ -12,119 +12,124 @@
|
|||||||
|
|
||||||
# Run this script as root or under sudo
|
# Run this script as root or under sudo
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ $EUID -eq 0 ]];then
|
||||||
echo "::: You are root."
|
echo "::: You are root."
|
||||||
else
|
else
|
||||||
echo "::: sudo will be used."
|
echo "::: sudo will be used."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [ -x "$(command -v sudo)" ];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this script as root."
|
echo "::: Please install sudo or run this script as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
piholeIPfile=/tmp/piholeIP
|
function helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Pull in domains from adlists"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole -g"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Options:"
|
||||||
|
echo "::: -f, --force Force lists to be downloaded, even if they don't need updating."
|
||||||
|
echo "::: -h, --help Show this help dialog"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
adListFile=/etc/pihole/adlists.list
|
adListFile=/etc/pihole/adlists.list
|
||||||
adListDefault=/etc/pihole/adlists.default
|
adListDefault=/etc/pihole/adlists.default
|
||||||
whitelistScript=/usr/local/bin/whitelist.sh
|
whitelistScript=/opt/pihole/whitelist.sh
|
||||||
blacklistScript=/usr/local/bin/blacklist.sh
|
blacklistScript=/opt/pihole/blacklist.sh
|
||||||
|
|
||||||
if [[ -f $piholeIPfile ]];then
|
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
|
# 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)
|
piholeIP=$(cat ${piholeIPfile})
|
||||||
rm $piholeIPfile
|
#rm $piholeIPfile
|
||||||
else
|
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
|
# 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)}')
|
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%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
if [[ -f ${piholeIPv6file} ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Variables for various stages of downloading and formatting the list
|
# Variables for various stages of downloading and formatting the list
|
||||||
|
## Nate 3/26/2016 - Commented unused variables
|
||||||
basename=pihole
|
basename=pihole
|
||||||
piholeDir=/etc/$basename
|
piholeDir=/etc/${basename}
|
||||||
adList=$piholeDir/gravity.list
|
adList=${piholeDir}/gravity.list
|
||||||
blacklist=$piholeDir/blacklist.txt
|
#blacklist=$piholeDir/blacklist.txt
|
||||||
whitelist=$piholeDir/whitelist.txt
|
#whitelist=$piholeDir/whitelist.txt
|
||||||
latentWhitelist=$piholeDir/latentWhitelist.txt
|
#latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||||
justDomainsExtension=domains
|
justDomainsExtension=domains
|
||||||
matterandlight=$basename.0.matterandlight.txt
|
matterandlight=${basename}.0.matterandlight.txt
|
||||||
supernova=$basename.1.supernova.txt
|
supernova=${basename}.1.supernova.txt
|
||||||
eventHorizon=$basename.2.eventHorizon.txt
|
eventHorizon=${basename}.2.eventHorizon.txt
|
||||||
accretionDisc=$basename.3.accretionDisc.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
|
# After setting defaults, check if there's local overrides
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
if [[ -r ${piholeDir}/pihole.conf ]];then
|
||||||
echo "::: Local calibration requested..."
|
echo "::: Local calibration requested..."
|
||||||
. $piholeDir/pihole.conf
|
. ${piholeDir}/pihole.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
spinner(){
|
|
||||||
local pid=$1
|
|
||||||
local delay=0.001
|
|
||||||
local spinstr='/-\|'
|
|
||||||
|
|
||||||
spin='-\|/'
|
|
||||||
i=0
|
|
||||||
while $SUDO kill -0 $pid 2>/dev/null
|
|
||||||
do
|
|
||||||
i=$(( (i+1) %4 ))
|
|
||||||
printf "\b${spin:$i:1}"
|
|
||||||
sleep .1
|
|
||||||
done
|
|
||||||
printf "\b"
|
|
||||||
}
|
|
||||||
###########################
|
###########################
|
||||||
# collapse - begin formation of pihole
|
# collapse - begin formation of pihole
|
||||||
function gravity_collapse() {
|
function gravity_collapse() {
|
||||||
echo "::: Neutrino emissions detected..."
|
echo "::: Neutrino emissions detected..."
|
||||||
echo ":::"
|
echo ":::"
|
||||||
#Decide if we're using a custom ad block list, or defaults.
|
#Decide if we're using a custom ad block list, or defaults.
|
||||||
if [ -f $adListFile ]; then
|
if [ -f ${adListFile} ]; then
|
||||||
#custom file found, use this instead of default
|
#custom file found, use this instead of default
|
||||||
echo -n "::: Custom adList file detected. Reading..."
|
echo -n "::: Custom adList file detected. Reading..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -r line; do
|
||||||
sources+=($line)
|
#Do not read commented out or blank lines
|
||||||
done < $adListFile
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo " done!"
|
echo "" > /dev/null
|
||||||
|
else
|
||||||
|
sources+=(${line})
|
||||||
|
fi
|
||||||
|
done < ${adListFile}
|
||||||
|
echo " done!"
|
||||||
else
|
else
|
||||||
#no custom file found, use defaults!
|
#no custom file found, use defaults!
|
||||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -r line; do
|
||||||
sources+=($line)
|
#Do not read commented out or blank lines
|
||||||
done < $adListDefault
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo " done!"
|
echo "" > /dev/null
|
||||||
fi
|
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
|
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
||||||
if [[ -d $piholeDir ]];then
|
if [[ -d ${piholeDir} ]];then
|
||||||
# Temporary hack to allow non-root access to pihole directory
|
# Temporary hack to allow non-root access to pihole directory
|
||||||
# Will update later, needed for existing installs, new installs should
|
# Will update later, needed for existing installs, new installs should
|
||||||
# create this directory as non-root
|
# create this directory as non-root
|
||||||
$SUDO chmod 777 $piholeDir
|
${SUDO} chmod 777 ${piholeDir}
|
||||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
echo ":::"
|
||||||
echo "."
|
echo "::: Existing pihole directory found"
|
||||||
else
|
else
|
||||||
echo -n "::: Creating pihole directory..."
|
echo "::: Creating pihole directory..."
|
||||||
mkdir $piholeDir & spinner $!
|
mkdir ${piholeDir}
|
||||||
echo " done!"
|
${SUDO} chmod 777 ${piholeDir}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +141,7 @@ function gravity_patternCheck() {
|
|||||||
# Some of the blocklists are copyright, they need to be downloaded
|
# Some of the blocklists are copyright, they need to be downloaded
|
||||||
# and stored as is. They can be processed for content after they
|
# and stored as is. They can be processed for content after they
|
||||||
# have been saved.
|
# have been saved.
|
||||||
cp $patternBuffer $saveLocation
|
cp "$patternBuffer" "$saveLocation"
|
||||||
echo " List updated, transport successful!"
|
echo " List updated, transport successful!"
|
||||||
else
|
else
|
||||||
# curl didn't download any host files, probably because of the date check
|
# curl didn't download any host files, probably because of the date check
|
||||||
@@ -153,23 +158,22 @@ function gravity_transport() {
|
|||||||
# tmp file, so we don't have to store the (long!) lists in RAM
|
# tmp file, so we don't have to store the (long!) lists in RAM
|
||||||
patternBuffer=$(mktemp)
|
patternBuffer=$(mktemp)
|
||||||
heisenbergCompensator=""
|
heisenbergCompensator=""
|
||||||
if [[ -r $saveLocation ]]; then
|
if [[ -r ${saveLocation} ]]; then
|
||||||
# if domain has been saved, add file for date check to only download newer
|
# if domain has been saved, add file for date check to only download newer
|
||||||
heisenbergCompensator="-z $saveLocation"
|
heisenbergCompensator="-z $saveLocation"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Silently curl url
|
# Silently curl url
|
||||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
curl -s -L ${cmd_ext} ${heisenbergCompensator} -A "$agent" ${url} > ${patternBuffer}
|
||||||
# Check for list updates
|
# Check for list updates
|
||||||
gravity_patternCheck $patternBuffer
|
gravity_patternCheck "$patternBuffer"
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -f $patternBuffer
|
rm -f "$patternBuffer"
|
||||||
}
|
}
|
||||||
|
|
||||||
# spinup - main gravity function
|
# spinup - main gravity function
|
||||||
function gravity_spinup() {
|
function gravity_spinup() {
|
||||||
echo "::: "
|
echo ":::"
|
||||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
||||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
for ((i = 0; i < "${#sources[@]}"; i++))
|
||||||
do
|
do
|
||||||
@@ -178,8 +182,8 @@ function gravity_spinup() {
|
|||||||
domain=$(echo "$url" | cut -d'/' -f3)
|
domain=$(echo "$url" | cut -d'/' -f3)
|
||||||
|
|
||||||
# Save the file as list.#.domain
|
# Save the file as list.#.domain
|
||||||
saveLocation=$piholeDir/list.$i.$domain.$justDomainsExtension
|
saveLocation=${piholeDir}/list.${i}.${domain}.${justDomainsExtension}
|
||||||
activeDomains[$i]=$saveLocation
|
activeDomains[$i]=${saveLocation}
|
||||||
|
|
||||||
agent="Mozilla/10.0"
|
agent="Mozilla/10.0"
|
||||||
|
|
||||||
@@ -188,17 +192,17 @@ function gravity_spinup() {
|
|||||||
# Use a case statement to download lists that need special cURL commands
|
# Use a case statement to download lists that need special cURL commands
|
||||||
# to complete properly and reset the user agent when required
|
# to complete properly and reset the user agent when required
|
||||||
case "$domain" in
|
case "$domain" in
|
||||||
"adblock.mahakala.is")
|
"adblock.mahakala.is")
|
||||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
agent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
||||||
cmd_ext="-e http://forum.xda-developers.com/"
|
cmd_ext="-e http://forum.xda-developers.com/"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"pgl.yoyo.org")
|
"pgl.yoyo.org")
|
||||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Default is a simple request
|
# Default is a simple request
|
||||||
*) cmd_ext=""
|
*) cmd_ext=""
|
||||||
esac
|
esac
|
||||||
gravity_transport "$url" "$cmd_ext" "$agent"
|
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||||
done
|
done
|
||||||
@@ -206,134 +210,154 @@ function gravity_spinup() {
|
|||||||
|
|
||||||
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
||||||
function gravity_Schwarzchild() {
|
function gravity_Schwarzchild() {
|
||||||
echo "::: "
|
echo "::: "
|
||||||
# Find all active domains and compile them into one file and remove CRs
|
# Find all active domains and compile them into one file and remove CRs
|
||||||
echo -n "::: Aggregating list of domains..."
|
echo -n "::: Aggregating list of domains..."
|
||||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
truncate -s 0 ${piholeDir}/${matterandlight}
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matterandlight
|
cat "$i" | tr -d '\r' >> ${piholeDir}/${matterandlight}
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function gravity_Blacklist(){
|
function gravity_Blacklist(){
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||||
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
${blacklistScript} -f -nr -q > /dev/null
|
||||||
|
|
||||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
||||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||||
echo " $numBlacklisted domain${plural} blacklisted!"
|
echo " $numBlacklisted domain${plural} blacklisted!"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function gravity_Whitelist() {
|
function gravity_Whitelist() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Prevent our sources from being pulled into the hole
|
# Prevent our sources from being pulled into the hole
|
||||||
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
||||||
echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..."
|
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
||||||
|
|
||||||
urls=()
|
urls=()
|
||||||
for url in ${sources[@]}
|
for url in "${sources[@]}"
|
||||||
do
|
do
|
||||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
||||||
urls=("${urls[@]}" $tmp)
|
urls=("${urls[@]}" ${tmp})
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||||
$whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $!
|
${whitelistScript} -f -nr -q "${urls[@]}" > /dev/null
|
||||||
|
|
||||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
echo " $numWhitelisted domain${plural} whitelisted!"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_unique() {
|
function gravity_unique() {
|
||||||
# Sort and remove duplicates
|
# Sort and remove duplicates
|
||||||
echo -n "::: Removing duplicate domains...."
|
echo -n "::: Removing duplicate domains...."
|
||||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $!
|
sort -u ${piholeDir}/${supernova} > ${piholeDir}/${eventHorizon}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
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() {
|
function gravity_hostFormat() {
|
||||||
# Format domain list as "192.168.x.x domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo "::: Formatting domains into a HOSTS file..."
|
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
|
hostname=$(</etc/hostname)
|
||||||
if [[ -n $piholeIPv6 ]];then
|
# 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
|
||||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
if [[ -n ${piholeIPv6} ]];then
|
||||||
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
# 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)
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
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
|
else
|
||||||
# Otherwise, just create gravity.list as normal using IPv4
|
# Otherwise, just create gravity.list as normal using IPv4
|
||||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
# 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 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
cp $piholeDir/$accretionDisc $adList
|
cp ${piholeDir}/${accretionDisc} ${adList}
|
||||||
}
|
}
|
||||||
|
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
function gravity_blackbody() {
|
function gravity_blackbody() {
|
||||||
# Loop through list files
|
# Loop through list files
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in ${piholeDir}/*.${justDomainsExtension}
|
||||||
do
|
do
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
rm -f $file
|
rm -f "$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_advanced() {
|
function gravity_advanced() {
|
||||||
|
|
||||||
|
|
||||||
# Remove comments and print only the domain name
|
# 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
|
# 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
|
# 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
|
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||||
echo -n "::: Formatting list of domains to remove comments...."
|
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 $!
|
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterandlight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
numberOf=$(wc -l < ${piholeDir}/${supernova})
|
||||||
echo "::: $numberOf domains being pulled in by gravity..."
|
echo "::: $numberOf domains being pulled in by gravity..."
|
||||||
|
|
||||||
gravity_unique
|
gravity_unique
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_reload() {
|
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
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
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)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
find "$piholeDir" -type f -exec ${SUDO} chmod 666 {} \;
|
||||||
|
|
||||||
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
${SUDO} killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start & spinner $!
|
${SUDO} service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
$SUDO cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
case "$var" in
|
||||||
|
"-f" | "--force" ) forceGrav=true;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
|
||||||
|
|
||||||
|
if [[ ${forceGrav} == true ]]; then
|
||||||
|
echo -n "::: Deleting exising list cache..."
|
||||||
|
${SUDO} rm /etc/pihole/list.*
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${SUDO} cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
|
|||||||
139
pihole
Executable file
139
pihole
Executable file
@@ -0,0 +1,139 @@
|
|||||||
|
#!/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 [ -x "$(command -v 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 updatePiholeFunc {
|
||||||
|
echo "::: Fetching latest changes from Github..."
|
||||||
|
cd /etc/.pihole
|
||||||
|
${SUDO} git pull
|
||||||
|
${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGravityFunc {
|
||||||
|
${SUDO} /opt/pihole/gravity.sh "$@"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupLCDFunction {
|
||||||
|
${SUDO} /opt/pihole/setupLCD.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryFunc {
|
||||||
|
domain=$2
|
||||||
|
for list in /etc/pihole/list.*;do echo $list;grep ${domain} $list;done
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function chronometerFunc {
|
||||||
|
shift
|
||||||
|
${SUDO} /opt/pihole/chronometer.sh "$@"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function uninstallFunc {
|
||||||
|
${SUDO} /opt/pihole/uninstall.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function versionFunc {
|
||||||
|
${SUDO} /opt/pihole/version.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function helpFunc {
|
||||||
|
echo "::: Control all PiHole specific functions!"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole [options]"
|
||||||
|
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
|
||||||
|
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 "::: -ud, updateDashboard Update the web dashboard manually"
|
||||||
|
echo "::: -up, updatePihole Update Pi-hole"
|
||||||
|
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 "::: -v, version Show current versions"
|
||||||
|
echo "::: -q, query Query the adlists for a specific domain"
|
||||||
|
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;;
|
||||||
|
"-ud" | "updateDashboard" ) updateDashboardFunc;;
|
||||||
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||||
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
|
"-h" | "help" ) helpFunc;;
|
||||||
|
"-v" | "version" ) versionFunc;;
|
||||||
|
"-q" | "query" ) queryFunc "$@";;
|
||||||
|
"uninstall" ) uninstallFunc;;
|
||||||
|
* ) helpFunc;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user