Compare commits
290 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0de74c0448 | ||
|
|
ee927346b7 | ||
|
|
fc89851ce9 | ||
|
|
c4c6555814 | ||
|
|
df0087fb23 | ||
|
|
ef3c13fe2b | ||
|
|
49f48e2aaa | ||
|
|
dce24df379 | ||
|
|
b59136c262 | ||
|
|
fb9664b636 | ||
|
|
5b736ae05e | ||
|
|
ee114b3075 | ||
|
|
123b16991b | ||
|
|
5792fc0bef | ||
|
|
42c93917ef | ||
|
|
8c0f860601 | ||
|
|
df30a4c0d1 | ||
|
|
9ce13f0035 | ||
|
|
3884b01503 | ||
|
|
a84c3adeab | ||
|
|
a65b784907 | ||
|
|
05dadad2e1 | ||
|
|
3a9b39b842 | ||
|
|
e612003293 | ||
|
|
a43577fa26 | ||
|
|
7e10dcdcf0 | ||
|
|
7ee1110351 | ||
|
|
51c4c51d9e | ||
|
|
fc4fe54099 | ||
|
|
b5b240d0be | ||
|
|
4c42f00a86 | ||
|
|
090fbd04af | ||
|
|
461de48625 | ||
|
|
9352ba6e4a | ||
|
|
5e883239f9 | ||
|
|
5ea08a2120 | ||
|
|
a6fa60868b | ||
|
|
99878ae7d6 | ||
|
|
26202014a2 | ||
|
|
f4f8b96788 | ||
|
|
e5ede16749 | ||
|
|
fbe3547129 | ||
|
|
23f7363c70 | ||
|
|
aa23fb1d56 | ||
|
|
4f35aac6dd | ||
|
|
4418ca9e9f | ||
|
|
570611fc09 | ||
|
|
94dd5b1ebe | ||
|
|
74524e024d | ||
|
|
324e00194f | ||
|
|
e42b6dcc8e | ||
|
|
d71b799e75 | ||
|
|
87e7121332 | ||
|
|
94f6354c94 | ||
|
|
b79059ebdb | ||
|
|
07b7e8a1a6 | ||
|
|
7ae2fc37c0 | ||
|
|
4f98c1bebb | ||
|
|
2feec01e10 | ||
|
|
72b95e192e | ||
|
|
47aad254d8 | ||
|
|
bc14074d2a | ||
|
|
5ab5b1a190 | ||
|
|
b055f190f5 | ||
|
|
84b8953352 | ||
|
|
93a591d487 | ||
|
|
e6c0f38a7c | ||
|
|
d169305e5d | ||
|
|
f107ae4f9b | ||
|
|
bad7a08804 | ||
|
|
25cbf4cb35 | ||
|
|
7f179f9a58 | ||
|
|
5287ea8537 | ||
|
|
43e2aaebf0 | ||
|
|
e60eb66283 | ||
|
|
ca59b808d8 | ||
|
|
8a15fd44d5 | ||
|
|
dac2b8942e | ||
|
|
54a1c5b63a | ||
|
|
61b02bf6d3 | ||
|
|
9d048b2fdf | ||
|
|
d9e28a7422 | ||
|
|
1fecdf42ca | ||
|
|
d4bf85b67c | ||
|
|
7131ff27c3 | ||
|
|
a30f78c1c8 | ||
|
|
7e0afffca8 | ||
|
|
293c60fb9c | ||
|
|
f5be8b2a5e | ||
|
|
6772603c15 | ||
|
|
a22904f99b | ||
|
|
6710d2852f | ||
|
|
b157bc5cd7 | ||
|
|
10e1a03c76 | ||
|
|
d20df92e9f | ||
|
|
44170207ac | ||
|
|
9354799a26 | ||
|
|
33745be745 | ||
|
|
6a28070017 | ||
|
|
91b948332e | ||
|
|
d1a7fe2d44 | ||
|
|
8224ef20a4 | ||
|
|
a4c3464bc8 | ||
|
|
5966d76e9a | ||
|
|
c39324d11f | ||
|
|
8c151c62ce | ||
|
|
50d16d8215 | ||
|
|
3bbac9a5f2 | ||
|
|
3600fd277e | ||
|
|
e8bb4a7e36 | ||
|
|
36987cb1cc | ||
|
|
5382b4fa37 | ||
|
|
28ef8068c8 | ||
|
|
ca0cbd68d6 | ||
|
|
c281b47905 | ||
|
|
aca5064743 | ||
|
|
6f780316c4 | ||
|
|
4e262d81f0 | ||
|
|
6c2ff950ee | ||
|
|
7684069d0b | ||
|
|
73c85ae68a | ||
|
|
911e39ba09 | ||
|
|
9a421d510a | ||
|
|
3bc7172e5e | ||
|
|
1a83988e26 | ||
|
|
0d0fc2504a | ||
|
|
0d4402ee0c | ||
|
|
722def9362 | ||
|
|
6a8bef83b3 | ||
|
|
a9c3e2c7ba | ||
|
|
7fcb40739d | ||
|
|
5a3d319677 | ||
|
|
8466d0b681 | ||
|
|
5de179f1eb | ||
|
|
36e10595cc | ||
|
|
78c8723629 | ||
|
|
edd7f28104 | ||
|
|
dba1ab3fc0 | ||
|
|
3df9c48012 | ||
|
|
6f6450bcff | ||
|
|
1f34203167 | ||
|
|
fed20648c6 | ||
|
|
3fc3c5cae4 | ||
|
|
daa5366b57 | ||
|
|
ac1c299369 | ||
|
|
5bbb3ac49a | ||
|
|
014bdf911a | ||
|
|
874853fe18 | ||
|
|
274b71f8bc | ||
|
|
c41d543d81 | ||
|
|
7729ddab30 | ||
|
|
60c0e59a83 | ||
|
|
ac49e639bd | ||
|
|
f01b20c2af | ||
|
|
a0d47be088 | ||
|
|
521374e238 | ||
|
|
34806ee2c2 | ||
|
|
4a0d5138a1 | ||
|
|
e6a3758899 | ||
|
|
fcb7d9111e | ||
|
|
d907731027 | ||
|
|
ac8d295bb9 | ||
|
|
a963beb96e | ||
|
|
21d4199a38 | ||
|
|
655c422c3c | ||
|
|
b6f8bd408f | ||
|
|
a3edd0b976 | ||
|
|
8e8efa5caf | ||
|
|
a41b8f62a2 | ||
|
|
452ee8c2df | ||
|
|
5ca6599ca9 | ||
|
|
dcedf6bfd0 | ||
|
|
1f4b43645b | ||
|
|
3d5140458b | ||
|
|
f16574085f | ||
|
|
3ed62d45f5 | ||
|
|
b1a7b0a186 | ||
|
|
ec0c68621c | ||
|
|
a0977af081 | ||
|
|
a3ef9efd2f | ||
|
|
d58f7c6ec9 | ||
|
|
d124c2c12e | ||
|
|
0229f70761 | ||
|
|
dde9281139 | ||
|
|
6eedfb572e | ||
|
|
edf81a232d | ||
|
|
c2cb92a0b0 | ||
|
|
640af300cb | ||
|
|
6c0c6182e9 | ||
|
|
05ad4445b5 | ||
|
|
1dd9f0747e | ||
|
|
150e01be8b | ||
|
|
95ee3216c4 | ||
|
|
3b5e409b38 | ||
|
|
eb201b614a | ||
|
|
162a6b8b5c | ||
|
|
4ec01769cb | ||
|
|
19b656132d | ||
|
|
6305c7e2ab | ||
|
|
04c60e8a1c | ||
|
|
b6ceb06a32 | ||
|
|
8cb2f85a08 | ||
|
|
7ccfb6ea88 | ||
|
|
531398b532 | ||
|
|
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 | ||
|
|
f0a2248c81 |
41
.github/ISSUE_TEMPLATE.md
vendored
41
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,7 +1,42 @@
|
|||||||
##### Expected Behaviour:
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
|
||||||
|
**In raising this issue, I confirm the following (please check boxes, eg [X]):**
|
||||||
|
|
||||||
|
- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
|
||||||
|
- [ ] The issue I am reporting can be *replicated*
|
||||||
|
- [ ] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)).
|
||||||
|
|
||||||
|
**How familiar are you with the codebase?:**
|
||||||
|
|
||||||
|
- [ ] 1 (very unfamiliar)
|
||||||
|
- [ ] 2
|
||||||
|
- [ ] 3
|
||||||
|
- [ ] 4
|
||||||
|
- [ ] 5
|
||||||
|
- [ ] 6
|
||||||
|
- [ ] 7
|
||||||
|
- [ ] 8
|
||||||
|
- [ ] 9
|
||||||
|
- [ ] 10 (very familiar)
|
||||||
|
|
||||||
|
---
|
||||||
|
**[FEATURE REQUEST | QUESTION | OTHER]:**
|
||||||
|
|
||||||
|
_{replace this section with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_
|
||||||
|
|
||||||
|
**[BUG | ISSUE] Expected Behaviour:**
|
||||||
|
|
||||||
|
|
||||||
##### Actual Behaviour:
|
**[BUG | ISSUE] Actual Behaviour:**
|
||||||
|
|
||||||
|
|
||||||
##### Steps to reproduce this issue:
|
**[BUG | ISSUE] Steps to reproduce:**
|
||||||
|
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
**(Optional) Debug Log generated by `pihole -d`:**
|
||||||
|
|
||||||
|
`http://termbin.com/<something>`
|
||||||
|
|||||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,11 +1,25 @@
|
|||||||
Fixes #[issue number] .
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
|
||||||
Changes proposed in this pull request:
|
**By submitting this pull request, I confirm the following (please check boxes, eg [X]):**
|
||||||
|
|
||||||
-
|
- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
|
||||||
|
- [ ] I have checked that [another pull request](https://github.com/pi-hole/pi-hole/pulls) for this purpose does not exist.
|
||||||
|
- [ ] I have considered, and confirmed that this submission will be valuable to others.
|
||||||
|
- [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
|
||||||
|
- [ ] I give this submission freely, and claim no ownership to its content.
|
||||||
|
|
||||||
-
|
**How familiar are you with the codebase?:**
|
||||||
|
|
||||||
-
|
- [ ] 1 (very unfamiliar)
|
||||||
|
- [ ] 2
|
||||||
|
- [ ] 3
|
||||||
|
- [ ] 4
|
||||||
|
- [ ] 5
|
||||||
|
- [ ] 6
|
||||||
|
- [ ] 7
|
||||||
|
- [ ] 8
|
||||||
|
- [ ] 9
|
||||||
|
- [ ] 10 (very familiar)
|
||||||
|
|
||||||
@pi-hole/gravity
|
---
|
||||||
|
_{replace this line with your pull request content}_
|
||||||
|
|||||||
38
.pullapprove.yml
Normal file
38
.pullapprove.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
always_pending:
|
||||||
|
title_regex: '(WIP|wip)'
|
||||||
|
labels:
|
||||||
|
- wip
|
||||||
|
explanation: 'This PR is a work in progress...'
|
||||||
|
|
||||||
|
group_defaults:
|
||||||
|
reset_on_push:
|
||||||
|
enabled: true
|
||||||
|
reject_value: -2
|
||||||
|
approve_regex: '^(Approved|:shipit:|:\+1:|Engage)'
|
||||||
|
reject_regex: '^(Rejected|:-1:|Borg)'
|
||||||
|
author_approval:
|
||||||
|
auto: true
|
||||||
|
|
||||||
|
|
||||||
|
groups:
|
||||||
|
development:
|
||||||
|
approve_by_comment:
|
||||||
|
enabled: true
|
||||||
|
conditions:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
required: 2
|
||||||
|
teams:
|
||||||
|
- gravity
|
||||||
|
|
||||||
|
master:
|
||||||
|
approve_by_comment:
|
||||||
|
enabled: true
|
||||||
|
conditions:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
required: 3
|
||||||
|
teams:
|
||||||
|
- gravity
|
||||||
@@ -1,8 +1,37 @@
|
|||||||
This is a basic checklist for now, We will update it in the future.
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
|
||||||
* Fork the repo and create your new branch based on the `development` branch.
|
# Contributors Guide
|
||||||
* Commit Unix line endings
|
|
||||||
* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
|
Please read and understand the contribution guide before creating an issue or pull request.
|
||||||
* Submit Pull Requests to the development branch only.
|
|
||||||
* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
## Etiquette
|
||||||
* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..
|
|
||||||
|
- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature.
|
||||||
|
- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that.
|
||||||
|
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
|
||||||
|
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
|
||||||
|
|
||||||
|
## Viability
|
||||||
|
|
||||||
|
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many people, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project.
|
||||||
|
|
||||||
|
## Procedure
|
||||||
|
|
||||||
|
**Before filing an issue:**
|
||||||
|
|
||||||
|
- Attempt to replicate and **document** the problem, to ensure that it wasn't a coincidental incident.
|
||||||
|
- Check to make sure your feature suggestion isn't already present within the project.
|
||||||
|
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
|
||||||
|
- Check the pull requests tab to ensure that the feature isn't already in progress.
|
||||||
|
|
||||||
|
**Before submitting a pull request:**
|
||||||
|
|
||||||
|
- Check the codebase to ensure that your feature doesn't already exist.
|
||||||
|
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
|
||||||
|
|
||||||
|
## Technical Requirements
|
||||||
|
|
||||||
|
- Submit Pull Requests to the **development branch only**.
|
||||||
|
- Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
||||||
|
- Commit Unix line endings.
|
||||||
|
- (Optional fun) keep to the theme of Star Trek/black holes/gravity.
|
||||||
|
|||||||
131
README.md
131
README.md
@@ -1,58 +1,65 @@
|
|||||||
# 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, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
|
||||||
|
|
||||||
1. Install Raspbian
|
# Automated Install
|
||||||
|
|
||||||
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!)
|
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!
|
||||||
|
|
||||||
### ```curl -L https://install.pi-hole.net | bash```
|
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!)
|
||||||
|
|
||||||
#### Alternative Semi-Automated install ####
|
## `curl -L https://install.pi-hole.net | bash`
|
||||||
```
|
|
||||||
|
### Alternative Semi-Automated install
|
||||||
|
|
||||||
|
```bash
|
||||||
wget -O basic-install.sh https://install.pi-hole.net
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
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
|
||||||
|
|
||||||
|
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/).
|
||||||
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/).
|
|
||||||
|
|
||||||
## How To Install Pi-hole
|
## How To Install Pi-hole
|
||||||
|
|
||||||
[](https://www.youtube.com/watch?v=TzFLJqUeirA)
|
[](https://www.youtube.com/watch?v=TzFLJqUeirA)
|
||||||
|
|
||||||
## How Does It Work?
|
## How It Works
|
||||||
|
|
||||||
**Watch the 60-second video below to get a quick overview**
|
**Watch the 60-second video below to get a quick overview**
|
||||||
|
|
||||||
[](https://youtu.be/9Eti3xibiho)
|
[](https://youtu.be/9Eti3xibiho)
|
||||||
|
|
||||||
## Pi-hole Is Free, But Powered By Your Donations
|
## Pi-hole Is Free, But Powered By Your Donations
|
||||||
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 montly fee.
|
|
||||||
*  : [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
|
|
||||||
*  : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission)
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-  : [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
|
||||||
|
|
||||||
## Get Help Or Connect With Us On The Web
|
## Get Help Or Connect With Us On The Web
|
||||||
|
|
||||||
- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
||||||
- [/r/pihole](https://www.reddit.com/r/pihole/)
|
- [/r/pihole](https://www.reddit.com/r/pihole/)
|
||||||
- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
|
- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
|
||||||
- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization)
|
- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization)
|
||||||
- [FAQs](https://pi-hole.net/help/)
|
- [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)
|
- [](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.
|
||||||
|
|
||||||
### 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)).
|
||||||
|
|
||||||
## 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:
|
|
||||||
|
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` or `http://pi.hole/admin`
|
`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin`
|
||||||
|
|
||||||
@@ -60,55 +67,59 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb
|
|||||||
|
|
||||||
### Whitelist and blacklist
|
### 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
|
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
|
## 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). 
|
||||||

|
|
||||||
|
|
||||||
## Pi-hole Projects
|
## Pi-hole Projects
|
||||||
- [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 stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
||||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
- [Docker Pi-hole container (x86 and ARM)](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))
|
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
||||||
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
|
||||||
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
||||||
- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
|
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
||||||
- [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 in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
|
||||||
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
|
- [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)
|
||||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
- [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
|
## 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)
|
- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI)
|
||||||
- [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/)
|
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
|
||||||
- [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)
|
- [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/)
|
||||||
- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585)
|
- [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)
|
||||||
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
|
- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585)
|
||||||
- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/)
|
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
|
||||||
- [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)!
|
- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/)
|
||||||
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
|
- [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 Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
|
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
|
||||||
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
|
||||||
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
||||||
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
- [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 is only for a clean install of a Debian based system, such as the Raspberry Pi.
|
|
||||||
|
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.
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||||
|
|
||||||
# Other lists we consider safe:
|
# Other lists we consider safe:
|
||||||
http://adblock.gjtech.net/?format=unix-hosts
|
|
||||||
http://mirror1.malwaredomains.com/files/justdomains
|
http://mirror1.malwaredomains.com/files/justdomains
|
||||||
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
|
||||||
|
|||||||
@@ -10,22 +10,7 @@
|
|||||||
# 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
|
helpFunc()
|
||||||
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 "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
@@ -47,9 +32,9 @@ fi
|
|||||||
|
|
||||||
#globals
|
#globals
|
||||||
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
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
@@ -61,9 +46,9 @@ domToRemoveList=()
|
|||||||
piholeIPfile=/etc/pihole/piholeIP
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
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
|
||||||
@@ -75,31 +60,31 @@ fi
|
|||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
|
||||||
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(){
|
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(){
|
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[@]}"; do
|
for dom in "${domList[@]}"; do
|
||||||
if "$addmode"; then
|
if "$addmode"; then
|
||||||
@@ -110,37 +95,37 @@ function PopBlacklistFile(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddDomain(){
|
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 $verbose; 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 $verbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 already exists in $blacklist! No need to add"
|
echo "::: $1 already exists in $blacklist! No need to add"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveDomain(){
|
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 $verbose; 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 $verbose; then
|
if ${verbose}; then
|
||||||
echo "::: Un-blacklisting $dom..."
|
echo "::: Un-blacklisting $dom..."
|
||||||
fi
|
fi
|
||||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||||
@@ -148,18 +133,18 @@ function RemoveDomain(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModifyHostFile(){
|
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
|
||||||
@@ -169,33 +154,41 @@ function ModifyHostFile(){
|
|||||||
#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() {
|
Reload() {
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
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 killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function DisplayBlist() {
|
DisplayBlist() {
|
||||||
verbose=false
|
verbose=false
|
||||||
echo -e " Displaying Gravity Affected Domains \n"
|
echo -e " Displaying Gravity Affected Domains \n"
|
||||||
count=1
|
count=1
|
||||||
@@ -223,15 +216,15 @@ done
|
|||||||
|
|
||||||
PopBlacklistFile
|
PopBlacklistFile
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
if ${modifyHost} || ${force}; then
|
||||||
ModifyHostFile
|
ModifyHostFile
|
||||||
else
|
else
|
||||||
if $verbose; 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
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ gravity="/etc/pihole/gravity.list"
|
|||||||
|
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
function CalcBlockedDomains(){
|
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
|
||||||
@@ -33,7 +33,7 @@ function CalcBlockedDomains(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcQueriesToday(){
|
CalcQueriesToday(){
|
||||||
if [ -e "$piLog" ];then
|
if [ -e "$piLog" ];then
|
||||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
@@ -41,15 +41,15 @@ function CalcQueriesToday(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcblockedToday(){
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcPercentBlockedToday(){
|
CalcPercentBlockedToday(){
|
||||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
||||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||||
@@ -61,15 +61,15 @@ function CalcPercentBlockedToday(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckIPv6(){
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputJSON(){
|
outputJSON(){
|
||||||
CalcQueriesToday
|
CalcQueriesToday
|
||||||
CalcblockedToday
|
CalcblockedToday
|
||||||
CalcPercentBlockedToday
|
CalcPercentBlockedToday
|
||||||
@@ -79,7 +79,7 @@ function outputJSON(){
|
|||||||
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalChrono(){
|
normalChrono(){
|
||||||
for (( ; ; ))
|
for (( ; ; ))
|
||||||
do
|
do
|
||||||
clear
|
clear
|
||||||
@@ -121,7 +121,7 @@ function normalChrono(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayHelp(){
|
displayHelp(){
|
||||||
echo "::: Displays stats about your piHole!"
|
echo "::: Displays stats about your piHole!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: sudo pihole -c [optional:-j]"
|
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||||
|
|||||||
@@ -3,16 +3,14 @@
|
|||||||
# (c) 2015, 2016 by Jacob Salmela
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
# http://pi-hole.net
|
# http://pi-hole.net
|
||||||
# Generates pihole_debug.log in /var/log/ to be used for troubleshooting.
|
# Generates pihole_debug.log to be used for troubleshooting.
|
||||||
#
|
#
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
# 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.
|
||||||
|
|
||||||
# Nate Brandeburg
|
set -o pipefail
|
||||||
# nate@ubiquisoft.com
|
|
||||||
# 3/24/2016
|
|
||||||
|
|
||||||
######## GLOBAL VARS ########
|
######## GLOBAL VARS ########
|
||||||
DEBUG_LOG="/var/log/pihole_debug.log"
|
DEBUG_LOG="/var/log/pihole_debug.log"
|
||||||
@@ -28,93 +26,188 @@ ADLISTSFILE="/etc/pihole/adlists.list"
|
|||||||
PIHOLELOG="/var/log/pihole.log"
|
PIHOLELOG="/var/log/pihole.log"
|
||||||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||||
|
|
||||||
|
# Header info and introduction
|
||||||
|
echo "::: Beginning Pi-hole debug at $(date)!"
|
||||||
|
echo "::: This debugging process will collect information from your running configuration,"
|
||||||
|
echo "::: and optionally upload the generated log to a unique and random directory on"
|
||||||
|
echo "::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only"
|
||||||
|
echo "::: person who is given the unique URL. Please consider where you post this link."
|
||||||
|
echo "::: "
|
||||||
|
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
# Must be root to debug
|
# Must be root to debug
|
||||||
if [[ $EUID -eq 0 ]]; then
|
if [[ "$EUID" -eq 0 ]]; then
|
||||||
echo "::: You are root... Beginning debug!"
|
echo "::: Script is executing as root user..."
|
||||||
else
|
else
|
||||||
echo "::: Sudo will be used for debugging."
|
echo "::: Non-root user detected..."
|
||||||
# Check if sudo is actually installed
|
# Check if sudo is actually installed
|
||||||
if [ -x "$(command -v sudo)" ]; then
|
if [ -x "$(command -v sudo)" ]; then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
|
echo "::: sudo command located, debug will run under sudo."
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this as root."
|
echo "::: Unable to locate sudo command. Please install sudo or run this as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure the file exists, create if not, clear if exists.
|
# Ensure the file exists, create if not, clear if exists.
|
||||||
if [ ! -f "$DEBUG_LOG" ]; then
|
if [ ! -f "$DEBUG_LOG" ]; then
|
||||||
$SUDO touch $DEBUG_LOG
|
${SUDO} touch ${DEBUG_LOG}
|
||||||
$SUDO chmod 644 $DEBUG_LOG
|
${SUDO} chmod 644 ${DEBUG_LOG}
|
||||||
$SUDO chown "$USER":root $DEBUG_LOG
|
${SUDO} chown "$USER":root ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
truncate -s 0 $DEBUG_LOG
|
truncate -s 0 ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Private functions exist here ###
|
### Private functions exist here ###
|
||||||
function versionCheck {
|
function log_write {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "$1" >> "${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 {
|
function version_check {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
log_write "############################################################"
|
||||||
echo "######## Distribution Section #########" >> $DEBUG_LOG
|
log_write "########## Installed Versions ##########"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
log_write "############################################################"
|
||||||
|
|
||||||
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 "::: Detecting Pi-hole installed versions."
|
||||||
echo "######## Whitelist Comparison #########" >> $DEBUG_LOG
|
pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
&& log_write "Pi-hole Version: $pi_hole_ver" || log_write "Pi-hole git repository not detected."
|
||||||
while read -r line; do
|
admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \
|
||||||
TMP=$(grep -w ".* $line$" "$GRAVITYFILE")
|
&& log_write "WebUI Version: $admin_ver" || log_write "Pi-hole Admin Pages git repository not detected."
|
||||||
if [ ! -z "$TMP" ]; then
|
|
||||||
echo "$TMP" >> $DEBUG_LOG
|
echo "::: Writing lighttpd version to logfile."
|
||||||
echo "$TMP" >> $WHITELISTMATCHES
|
light_ver="$(lighttpd -v |& head -n1)" && log_write "${light_ver}" || log_write "lighttpd not installed."
|
||||||
fi
|
|
||||||
done < "$WHITELISTFILE"
|
echo "::: Writing PHP version to logfile."
|
||||||
echo >> $DEBUG_LOG
|
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareBlacklist {
|
function distro_check {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG
|
echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
while read -r line; do
|
|
||||||
if [ ! -z "$line" ]; then
|
echo "::: Checking installed OS Distribution release."
|
||||||
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG
|
TMP=$(cat /etc/*release || echo "Failed to find release")
|
||||||
fi
|
|
||||||
done < "$BLACKLISTFILE"
|
echo "::: Writing OS Distribution release to logfile."
|
||||||
echo >> $DEBUG_LOG
|
echo "$TMP" >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNslookup {
|
function ip_check {
|
||||||
TESTURL="doubleclick.com"
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "######## IP Address Information #########" >> ${DEBUG_LOG}
|
||||||
echo "############ NSLookup Test ############" >> $DEBUG_LOG
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
|
echo "::: Writing local IPs to logfile"
|
||||||
|
IPADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')"
|
||||||
|
echo "$IPADDR" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
IP6ADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')" \
|
||||||
|
&& echo "$IP6ADDR" >> ${DEBUG_LOG} || echo "No IPv6 addresses found." >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "::: Locating default gateway and checking connectivity"
|
||||||
|
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "::: Pinging default IPv4 gateway..."
|
||||||
|
GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv4 Gateway check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv4 Gateway check failed:" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "::: Pinging Internet via IPv4..."
|
||||||
|
INET_CHECK=$(ping -q -w 5 -c 3 -n 8.8.8.8 | tail -n3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv4 Internet check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv4 Internet check failed:" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
echo "$INET_CHECK" >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "::: Pinging default IPv6 gateway..."
|
||||||
|
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}" | tail -n3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv6 Gateway check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv6 Gateway check failed:" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::: Pinging Internet via IPv6..."
|
||||||
|
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n 2001:4860:4860::8888 | tail -n3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv6 Internet check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv6 Internet check failed:" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
GATEWAY_CHECK="No IPv6 Gateway Detected"
|
||||||
|
fi
|
||||||
|
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hostnameCheck {
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
echo "######## Hostname Information #########" >> ${DEBUG_LOG}
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "::: Writing locally configured hostnames to logfile"
|
||||||
|
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
|
||||||
|
echo "This Pi-hole is: $(hostname)" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "::: Writing hosts file to debug log..."
|
||||||
|
echo "### Hosts ###" >> ${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
|
||||||
|
}
|
||||||
|
|
||||||
|
function portCheck {
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
echo "######## Open Port Information #########" >> ${DEBUG_LOG}
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "::: Detecting local server port 80 and 53 processes."
|
||||||
|
|
||||||
|
${SUDO} lsof -i :80 >> ${DEBUG_LOG}
|
||||||
|
${SUDO} lsof -i :53 >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testResolver {
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG}
|
||||||
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
|
||||||
# Find a blocked url that has not been whitelisted.
|
# Find a blocked url that has not been whitelisted.
|
||||||
|
TESTURL="doubleclick.com"
|
||||||
if [ -s "$WHITELISTMATCHES" ]; then
|
if [ -s "$WHITELISTMATCHES" ]; then
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
CUTURL=${line#*" "}
|
CUTURL=${line#*" "}
|
||||||
@@ -130,190 +223,198 @@ function testNslookup {
|
|||||||
done < "$GRAVITYFILE"
|
done < "$GRAVITYFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG
|
echo "Resolution of $TESTURL from Pi-hole:" >> ${DEBUG_LOG}
|
||||||
nslookup "$TESTURL" >> $DEBUG_LOG
|
LOCALDIG=$(dig "$TESTURL" @127.0.0.1)
|
||||||
echo >> $DEBUG_LOG
|
if [[ $? = 0 ]]
|
||||||
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG
|
then
|
||||||
nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG
|
echo "$LOCALDIG" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
else
|
||||||
|
echo "Failed to resolve $TESTURL on Pi-hole" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
|
||||||
|
echo "Resolution of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG}
|
||||||
|
REMOTEDIG=$(dig "$TESTURL" @8.8.8.8)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "$REMOTEDIG" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "Failed to resolve $TESTURL on 8.8.8.8" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
|
|
||||||
|
echo "Pi-hole dnsmasq specific records lookups" >> ${DEBUG_LOG}
|
||||||
|
echo "Cache Size:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt cachesize.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Insertions count:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt insertions.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Evictions count:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt evictions.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Misses count:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt misses.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Hits count:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt hits.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Auth count:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt auth.bind >> ${DEBUG_LOG}
|
||||||
|
echo "Upstream Servers:" >> ${DEBUG_LOG}
|
||||||
|
dig +short chaos txt servers.bind >> ${DEBUG_LOG}
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkProcesses {
|
function checkProcesses {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "########### Processes Check ###########" >> $DEBUG_LOG
|
echo "########### Processes Check ###########" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Logging status of lighttpd and dnsmasq..."
|
echo "::: Logging status of lighttpd and dnsmasq..."
|
||||||
PROCESSES=( lighttpd dnsmasq )
|
PROCESSES=( lighttpd dnsmasq )
|
||||||
for i in "${PROCESSES[@]}"
|
for i in "${PROCESSES[@]}"
|
||||||
do
|
do
|
||||||
echo "" >> $DEBUG_LOG
|
echo "" >> ${DEBUG_LOG}
|
||||||
echo -n "$i" >> "$DEBUG_LOG"
|
echo -n "$i" >> "$DEBUG_LOG"
|
||||||
echo " processes status:" >> $DEBUG_LOG
|
echo " processes status:" >> ${DEBUG_LOG}
|
||||||
$SUDO systemctl -l status "$i" >> "$DEBUG_LOG"
|
${SUDO} systemctl -l status "$i" >> "$DEBUG_LOG"
|
||||||
done
|
done
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugLighttpd {
|
function debugLighttpd {
|
||||||
echo "::: Writing lighttpd to debug log..."
|
echo "::: Writing lighttpd to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
|
echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$LIGHTTPDFILE" ]
|
if [ -e "$LIGHTTPDFILE" ]
|
||||||
then
|
then
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [ ! -z "$line" ]; then
|
if [ ! -z "$line" ]; then
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
[[ "$line" =~ ^#.*$ ]] && continue
|
||||||
echo "$line" >> $DEBUG_LOG
|
echo "$line" >> ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
done < "$LIGHTTPDFILE"
|
done < "$LIGHTTPDFILE"
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
|
echo "No lighttpd.conf file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo lighttpd.conf file found\n"
|
printf ":::\tNo lighttpd.conf file found\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$LIGHTTPDERRFILE" ]
|
if [ -e "$LIGHTTPDERRFILE" ]
|
||||||
then
|
then
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "######### lighttpd error.log ##########" >> $DEBUG_LOG
|
echo "######### lighttpd error.log ##########" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG
|
cat "$LIGHTTPDERRFILE" >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No lighttpd error.log file found!" >> $DEBUG_LOG
|
echo "No lighttpd error.log file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo lighttpd error.log file found\n"
|
printf ":::\tNo lighttpd error.log file found\n"
|
||||||
fi
|
fi
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
### END FUNCTIONS ###
|
### END FUNCTIONS ###
|
||||||
|
|
||||||
### Check Pi internet connections ###
|
version_check
|
||||||
# Log the IP addresses of this Pi
|
distro_check
|
||||||
IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e')
|
ip_check
|
||||||
echo "::: Writing local IPs to debug log"
|
hostnameCheck
|
||||||
echo "IP Addresses of this Pi:" >> $DEBUG_LOG
|
portCheck
|
||||||
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
|
checkProcesses
|
||||||
|
testResolver
|
||||||
debugLighttpd
|
debugLighttpd
|
||||||
|
|
||||||
echo "::: Writing dnsmasq.conf to debug log..."
|
echo "::: Writing dnsmasq.conf to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############### Dnsmasq ###############" >> $DEBUG_LOG
|
echo "############### Dnsmasq ###############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$DNSMASQFILE" ]
|
if [ -e "$DNSMASQFILE" ]
|
||||||
then
|
then
|
||||||
#cat $DNSMASQFILE >> $DEBUG_LOG
|
#cat $DNSMASQFILE >> $DEBUG_LOG
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [ ! -z "$line" ]; then
|
if [ ! -z "$line" ]; then
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
[[ "$line" =~ ^#.*$ ]] && continue
|
||||||
echo "$line" >> $DEBUG_LOG
|
echo "$line" >> ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
done < "$DNSMASQFILE"
|
done < "$DNSMASQFILE"
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No dnsmasq.conf file found!" >> $DEBUG_LOG
|
echo "No dnsmasq.conf file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo dnsmasq.conf file found!\n"
|
printf ":::\tNo dnsmasq.conf file found!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Writing 01-pihole.conf to debug log..."
|
echo "::: Writing 01-pihole.conf to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
|
echo "########### 01-pihole.conf ############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$PIHOLECONFFILE" ]
|
if [ -e "$PIHOLECONFFILE" ]
|
||||||
then
|
then
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [ ! -z "$line" ]; then
|
if [ ! -z "$line" ]; then
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
[[ "$line" =~ ^#.*$ ]] && continue
|
||||||
echo "$line" >> $DEBUG_LOG
|
echo "$line" >> ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
done < "$PIHOLECONFFILE"
|
done < "$PIHOLECONFFILE"
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No 01-pihole.conf file found!" >> $DEBUG_LOG
|
echo "No 01-pihole.conf file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo 01-pihole.conf file found\n"
|
printf ":::\tNo 01-pihole.conf file found\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Writing size of gravity.list to debug log..."
|
echo "::: Writing size of gravity.list to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############ gravity.list #############" >> $DEBUG_LOG
|
echo "############ gravity.list #############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$GRAVITYFILE" ]
|
if [ -e "$GRAVITYFILE" ]
|
||||||
then
|
then
|
||||||
wc -l "$GRAVITYFILE" >> $DEBUG_LOG
|
wc -l "$GRAVITYFILE" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No gravity.list file found!" >> $DEBUG_LOG
|
echo "No gravity.list file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo gravity.list file found\n"
|
printf ":::\tNo gravity.list file found\n"
|
||||||
fi
|
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..."
|
### Pi-hole application specific logging ###
|
||||||
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 "::: Writing whitelist to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############## Whitelist ##############" >> $DEBUG_LOG
|
echo "############## Whitelist ##############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$WHITELISTFILE" ]
|
if [ -e "$WHITELISTFILE" ]
|
||||||
then
|
then
|
||||||
cat "$WHITELISTFILE" >> $DEBUG_LOG
|
cat "$WHITELISTFILE" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No whitelist.txt file found!" >> $DEBUG_LOG
|
echo "No whitelist.txt file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo whitelist.txt file found!\n"
|
printf ":::\tNo whitelist.txt file found!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Writing blacklist to debug log..."
|
echo "::: Writing blacklist to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############## Blacklist ##############" >> $DEBUG_LOG
|
echo "############## Blacklist ##############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$BLACKLISTFILE" ]
|
if [ -e "$BLACKLISTFILE" ]
|
||||||
then
|
then
|
||||||
cat "$BLACKLISTFILE" >> $DEBUG_LOG
|
cat "$BLACKLISTFILE" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No blacklist.txt file found!" >> $DEBUG_LOG
|
echo "No blacklist.txt file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo blacklist.txt file found!\n"
|
printf ":::\tNo blacklist.txt file found!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Writing adlists.list to debug log..."
|
echo "::: Writing adlists.list to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############ adlists.list #############" >> $DEBUG_LOG
|
echo "############ adlists.list #############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$ADLISTSFILE" ]
|
if [ -e "$ADLISTSFILE" ]
|
||||||
then
|
then
|
||||||
cat "$ADLISTSFILE" >> $DEBUG_LOG
|
while read -r line; do
|
||||||
echo >> $DEBUG_LOG
|
if [ ! -z "$line" ]; then
|
||||||
|
[[ "$line" =~ ^#.*$ ]] && continue
|
||||||
|
echo "$line" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
done < "$ADLISTSFILE"
|
||||||
|
echo >> ${DEBUG_LOG}
|
||||||
else
|
else
|
||||||
echo "No adlists.list file found... using adlists.default!" >> $DEBUG_LOG
|
echo "No adlists.list file found... using adlists.default!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo adlists.list file found... using adlists.default!\n"
|
printf ":::\tNo adlists.list file found... using adlists.default!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -321,35 +422,45 @@ fi
|
|||||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
function dumpPiHoleLog {
|
function dumpPiHoleLog {
|
||||||
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
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 -e "::: Writing current Pi-hole 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 "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
echo "############# pihole.log ##############" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
if [ -e "$PIHOLELOG" ]
|
if [ -e "$PIHOLELOG" ]
|
||||||
then
|
then
|
||||||
while true; do
|
while true; do
|
||||||
tail -f "$PIHOLELOG" >> $DEBUG_LOG
|
tail -f "$PIHOLELOG" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
echo >> ${DEBUG_LOG}
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "No pihole.log file found!" >> $DEBUG_LOG
|
echo "No pihole.log file found!" >> ${DEBUG_LOG}
|
||||||
printf ":::\tNo pihole.log file found!\n"
|
printf ":::\tNo pihole.log file found!\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Anything to be done after capturing of pihole.log terminates
|
# Anything to be done after capturing of pihole.log terminates
|
||||||
function finalWork {
|
function finalWork {
|
||||||
echo "::: Finshed debugging!"
|
echo "::: Finshed debugging!"
|
||||||
TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999)
|
echo "::: The debug 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
|
# Check if termbin.com is reachable. When it's not, point to local log instead
|
||||||
if [ -n "$TERMBIN" ]
|
if [ -n "$TERMBIN" ]
|
||||||
then
|
then
|
||||||
echo "::: Debug log can be found at : $TERMBIN"
|
echo "::: Debug log can be found at : $TERMBIN"
|
||||||
else
|
else
|
||||||
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
### Method calls for additional logging ###
|
### Method calls for additional logging ###
|
||||||
|
|||||||
@@ -11,5 +11,5 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
echo -n "::: Flushing /var/log/pihole.log ..."
|
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||||
truncate -s 0 /var/log/pihole.log
|
echo " " > /var/log/pihole.log
|
||||||
echo "... done!"
|
echo "... done!"
|
||||||
|
|||||||
@@ -11,21 +11,6 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
############ FUNCTIONS ###########
|
############ 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
|
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
|
||||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
||||||
@@ -44,12 +29,12 @@ getInitSys() {
|
|||||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
||||||
autoLoginPiToConsole() {
|
autoLoginPiToConsole() {
|
||||||
if [ -e /etc/init.d/lightdm ]; then
|
if [ -e /etc/init.d/lightdm ]; then
|
||||||
if [ $SYSTEMD -eq 1 ]; then
|
if [ ${SYSTEMD} -eq 1 ]; then
|
||||||
$SUDO systemctl set-default multi-user.target
|
systemctl set-default multi-user.target
|
||||||
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||||||
else
|
else
|
||||||
$SUDO update-rc.d lightdm disable 2
|
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/"
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -66,23 +51,23 @@ echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
|
|||||||
|
|
||||||
# Set up the LCD screen based on Adafruits instuctions:
|
# Set up the LCD screen based on Adafruits instuctions:
|
||||||
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
|
# 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
|
curl -SLs https://apt.adafruit.com/add-pin | bash
|
||||||
$SUDO apt-get -y install raspberrypi-bootloader
|
apt-get -y install raspberrypi-bootloader
|
||||||
$SUDO apt-get -y install adafruit-pitft-helper
|
apt-get -y install adafruit-pitft-helper
|
||||||
$SUDO adafruit-pitft-helper -t 28r
|
adafruit-pitft-helper -t 28r
|
||||||
|
|
||||||
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
|
# 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
|
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
|
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
|
# Back up the original file and download the new one
|
||||||
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig
|
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
|
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
|
# Instantly apply the font change to the LCD screen
|
||||||
$SUDO setupcon
|
setupcon
|
||||||
|
|
||||||
$SUDO reboot
|
reboot
|
||||||
|
|
||||||
# Start showing the stats on the screen by running the command on another tty:
|
# 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
|
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# Updates the Pi-hole web interface
|
|
||||||
#
|
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
|
||||||
WEB_INTERFACE_DIR="/var/www/html/admin"
|
|
||||||
|
|
||||||
main() {
|
|
||||||
prerequisites
|
|
||||||
if ! is_repo; then
|
|
||||||
make_repo
|
|
||||||
fi
|
|
||||||
update_repo
|
|
||||||
}
|
|
||||||
|
|
||||||
prerequisites() {
|
|
||||||
|
|
||||||
# must be root to update
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
sudo bash "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# web interface must already exist. this is a (lazy)
|
|
||||||
# check to make sure pihole is actually installed.
|
|
||||||
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
|
|
||||||
echo "$WEB_INTERFACE_DIR not found. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! type "git" > /dev/null; then
|
|
||||||
apt-get -y install git
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_repo() {
|
|
||||||
# if the web interface directory does not have a .git folder
|
|
||||||
# it means its using the master.zip archive from the install
|
|
||||||
# script.
|
|
||||||
if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# removes the web interface installed from the master.zip archive and
|
|
||||||
# replaces it with the current master branch from github
|
|
||||||
make_repo() {
|
|
||||||
# remove the non-repod interface and clone the interface
|
|
||||||
rm -rf $WEB_INTERFACE_DIR
|
|
||||||
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
# pulls the latest master branch from github
|
|
||||||
update_repo() {
|
|
||||||
# pull the latest commits
|
|
||||||
cd "$WEB_INTERFACE_DIR"
|
|
||||||
git pull
|
|
||||||
}
|
|
||||||
|
|
||||||
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,22 +10,8 @@
|
|||||||
# 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()
|
helpFunc()
|
||||||
{
|
{
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
@@ -47,9 +33,9 @@ fi
|
|||||||
|
|
||||||
#globals
|
#globals
|
||||||
basename=pihole
|
basename=pihole
|
||||||
piholeDir=/etc/$basename
|
piholeDir=/etc/${basename}
|
||||||
adList=$piholeDir/gravity.list
|
adList=${piholeDir}/gravity.list
|
||||||
whitelist=$piholeDir/whitelist.txt
|
whitelist=${piholeDir}/whitelist.txt
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
@@ -61,9 +47,9 @@ domToRemoveList=()
|
|||||||
piholeIPfile=/etc/pihole/piholeIP
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
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
|
||||||
@@ -75,34 +61,34 @@ fi
|
|||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
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(){
|
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(){
|
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"
|
||||||
@@ -110,35 +96,35 @@ function PopWhitelistFile(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddDomain(){
|
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 $verbose; then
|
if ${verbose}; then
|
||||||
echo -n "::: Adding $1 to $whitelist..."
|
echo -n "::: Adding $1 to $whitelist..."
|
||||||
fi
|
fi
|
||||||
echo "$1" >> $whitelist
|
echo "$1" >> ${whitelist}
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
if $verbose; then
|
if ${verbose}; then
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if $verbose; then
|
if ${verbose}; then
|
||||||
echo "::: $1 already exists in $whitelist, no need to add!"
|
echo "::: $1 already exists in $whitelist, no need to add!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveDomain(){
|
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 $verbose; 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
|
||||||
@@ -151,22 +137,22 @@ function RemoveDomain(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModifyHostFile(){
|
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 -r 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 -r 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 $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp
|
grep -F -x -v -f ${piholeDir}/whitelist.tmp ${adList} > ${piholeDir}/gravity.tmp
|
||||||
rm $adList
|
rm ${adList}
|
||||||
mv $piholeDir/gravity.tmp $adList
|
mv ${piholeDir}/gravity.tmp ${adList}
|
||||||
rm $piholeDir/whitelist.tmp
|
rm ${piholeDir}/whitelist.tmp
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -175,40 +161,51 @@ function ModifyHostFile(){
|
|||||||
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..."
|
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..."
|
||||||
|
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelist}
|
||||||
|
echo " done!"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function Reload() {
|
Reload() {
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
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 killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function DisplayWlist() {
|
DisplayWlist() {
|
||||||
verbose=false
|
verbose=false
|
||||||
echo -e " Displaying Gravity Resistant Domains \n"
|
echo -e " Displaying Gravity Resistant Domains \n"
|
||||||
count=1
|
count=1
|
||||||
@@ -236,16 +233,16 @@ done
|
|||||||
|
|
||||||
PopWhitelistFile
|
PopWhitelistFile
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
if ${modifyHost} || ${force}; then
|
||||||
ModifyHostFile
|
ModifyHostFile
|
||||||
else
|
else
|
||||||
if $verbose; then
|
if ${verbose}; then
|
||||||
echo ":::"
|
echo ":::"
|
||||||
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
|
||||||
@@ -4,7 +4,7 @@ _pihole()
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer uninstall help"
|
opts="blacklist chronometer debug flush help query reconfigure setupLCD uninstall updateGravity updatePihole version whitelist"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<script>window.close();</script>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ mimetype.assign = ( ".png" => "image/png",
|
|||||||
".css" => "text/css; charset=utf-8",
|
".css" => "text/css; charset=utf-8",
|
||||||
".js" => "application/javascript",
|
".js" => "application/javascript",
|
||||||
".json" => "application/json",
|
".json" => "application/json",
|
||||||
".txt" => "text/plain" )
|
".txt" => "text/plain",
|
||||||
|
".svg" => "image/svg+xml" )
|
||||||
|
|
||||||
# default listening port for IPv6 falls back to the IPv4 port
|
# 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/use-ipv6.pl " + server.port
|
||||||
|
|||||||
@@ -13,14 +13,13 @@
|
|||||||
# Download any updates from the adlists
|
# Download any updates from the adlists
|
||||||
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
||||||
|
|
||||||
# Pi-hole: Update the Web interface shortly after gravity runs
|
# Pi-hole: Update Pi-hole! Uncomment to enable auto update
|
||||||
# This should also update the version number if it is changed in the dashboard repo
|
#30 2 * * 7 root /usr/local/bin/pihole updatePihole
|
||||||
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 # note: this is outdated
|
#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 00:00 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/pihole flush
|
00 00 * * * root /usr/local/bin/pihole flush
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ if [ -x "$(command -v rpm)" ];then
|
|||||||
rpm -qa | grep ^$1- > /dev/null
|
rpm -qa | grep ^$1- > /dev/null
|
||||||
}
|
}
|
||||||
package_cleanup() {
|
package_cleanup() {
|
||||||
$SUDO $PKG_MANAGER -y autoremove
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
}
|
}
|
||||||
elif [ -x "$(command -v apt-get)" ];then
|
elif [ -x "$(command -v apt-get)" ];then
|
||||||
# Debian Family
|
# Debian Family
|
||||||
@@ -50,8 +50,8 @@ elif [ -x "$(command -v apt-get)" ];then
|
|||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
||||||
}
|
}
|
||||||
package_cleanup() {
|
package_cleanup() {
|
||||||
$SUDO $PKG_MANAGER -y autoremove
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
$SUDO $PKG_MANAGER -y autoclean
|
${SUDO} ${PKG_MANAGER} -y autoclean
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "OS distribution not supported"
|
echo "OS distribution not supported"
|
||||||
@@ -66,8 +66,8 @@ spinner()
|
|||||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||||
local temp=${spinstr#?}
|
local temp=${spinstr#?}
|
||||||
printf " [%c] " "$spinstr"
|
printf " [%c] " "$spinstr"
|
||||||
local spinstr=$temp${spinstr%"$temp"}
|
local spinstr=${temp}${spinstr%"$temp"}
|
||||||
sleep $delay
|
sleep ${delay}
|
||||||
printf "\b\b\b\b\b\b"
|
printf "\b\b\b\b\b\b"
|
||||||
done
|
done
|
||||||
printf " \b\b\b\b"
|
printf " \b\b\b\b"
|
||||||
@@ -77,12 +77,12 @@ function removeAndPurge {
|
|||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ":::"
|
echo ":::"
|
||||||
for i in "${PIHOLE_DEPS[@]}"; do
|
for i in "${PIHOLE_DEPS[@]}"; do
|
||||||
package_check $i > /dev/null
|
package_check ${i} > /dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
while true; do
|
while true; do
|
||||||
read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn
|
read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn
|
||||||
case $yn in
|
case ${yn} in
|
||||||
[Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO $PKG_REMOVE "$i" &> /dev/null & spinner $!; printf "done!\n"; break;;
|
[Yy]* ) printf ":::\tRemoving %s..." "$i"; ${SUDO} ${PKG_REMOVE} "$i" &> /dev/null & spinner $!; printf "done!\n"; break;;
|
||||||
[Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;;
|
[Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;;
|
||||||
* ) printf "::: You must answer yes or no!\n";;
|
* ) printf "::: You must answer yes or no!\n";;
|
||||||
esac
|
esac
|
||||||
@@ -94,7 +94,7 @@ echo ":::"
|
|||||||
|
|
||||||
# Remove dependency config files
|
# Remove dependency config files
|
||||||
echo "::: Removing dnsmasq config files..."
|
echo "::: Removing dnsmasq config files..."
|
||||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
|
|
||||||
# Take care of any additional package cleaning
|
# Take care of any additional package cleaning
|
||||||
printf "::: Auto removing & cleaning remaining dependencies..."
|
printf "::: Auto removing & cleaning remaining dependencies..."
|
||||||
@@ -108,14 +108,14 @@ function removeNoPurge {
|
|||||||
echo ":::"
|
echo ":::"
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
# Only web directories/files that are created by pihole should be removed.
|
||||||
echo "::: Removing the Pi-hole Web server files..."
|
echo "::: Removing the Pi-hole Web server files..."
|
||||||
$SUDO rm -rf /var/www/html/admin &> /dev/null
|
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
||||||
$SUDO rm -rf /var/www/html/pihole &> /dev/null
|
${SUDO} rm -rf /var/www/html/pihole &> /dev/null
|
||||||
$SUDO rm /var/www/html/index.lighttpd.orig &> /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 the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||||
if [ -d "/var/www/html" ]; then
|
if [ -d "/var/www/html" ]; then
|
||||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||||
$SUDO rm -rf /var/www/html &> /dev/null
|
${SUDO} rm -rf /var/www/html &> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -125,36 +125,36 @@ function removeNoPurge {
|
|||||||
# preserved.
|
# preserved.
|
||||||
if [[ -f /etc/crontab.orig ]]; then
|
if [[ -f /etc/crontab.orig ]]; then
|
||||||
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
||||||
$SUDO mv /etc/crontab /etc/crontab.pihole
|
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
||||||
$SUDO mv /etc/crontab.orig /etc/crontab
|
${SUDO} mv /etc/crontab.orig /etc/crontab
|
||||||
$SUDO service cron restart
|
${SUDO} service cron restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
if [[ -f /etc/cron.d/pihole ]];then
|
if [[ -f /etc/cron.d/pihole ]];then
|
||||||
echo "::: Removing cron.d/pihole..."
|
echo "::: Removing cron.d/pihole..."
|
||||||
$SUDO rm /etc/cron.d/pihole &> /dev/null
|
${SUDO} rm /etc/cron.d/pihole &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Removing config files and scripts..."
|
echo "::: Removing config files and scripts..."
|
||||||
package_check $i > /dev/null
|
package_check ${i} > /dev/null
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
$SUDO rm -rf /etc/lighttpd/ &> /dev/null
|
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
||||||
else
|
else
|
||||||
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null
|
||||||
$SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
$SUDO rm -rf /var/log/*pihole* &> /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 /etc/.pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/.pihole/ &> /dev/null
|
||||||
$SUDO rm -rf /opt/pihole/ &> /dev/null
|
${SUDO} rm -rf /opt/pihole/ &> /dev/null
|
||||||
$SUDO rm /usr/local/bin/pihole &> /dev/null
|
${SUDO} rm /usr/local/bin/pihole &> /dev/null
|
||||||
$SUDO rm /etc/bash_completion.d/pihole &> /dev/null
|
${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null
|
||||||
$SUDO rm /etc/sudoers.d/pihole &> /dev/null
|
${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||||
@@ -168,7 +168,7 @@ echo "::: Preparing to remove packages, be sure that each may be safely removed
|
|||||||
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
||||||
while true; do
|
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
|
read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn
|
||||||
case $yn in
|
case ${yn} in
|
||||||
[Yy]* ) removeAndPurge; break;;
|
[Yy]* ) removeAndPurge; break;;
|
||||||
|
|
||||||
[Nn]* ) removeNoPurge; break;;
|
[Nn]* ) removeNoPurge; break;;
|
||||||
|
|||||||
213
gravity.sh
213
gravity.sh
@@ -13,83 +13,70 @@
|
|||||||
# Run this script as root or under sudo
|
# Run this script as root or under sudo
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
helpFunc()
|
||||||
echo "::: You are root."
|
{
|
||||||
else
|
echo "::: Pull in domains from adlists"
|
||||||
echo "::: sudo will be used."
|
echo ":::"
|
||||||
# Check if it is actually installed
|
echo "::: Usage: pihole -g"
|
||||||
# If it isn't, exit because the install cannot complete
|
echo ":::"
|
||||||
if [ -x "$(command -v sudo)" ];then
|
echo "::: Options:"
|
||||||
export SUDO="sudo"
|
echo "::: -f, --force Force lists to be downloaded, even if they don't need updating."
|
||||||
else
|
echo "::: -h, --help Show this help dialog"
|
||||||
echo "::: Please install sudo or run this script as root."
|
exit 1
|
||||||
exit 1
|
}
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
piholeIPfile=/etc/pihole/piholeIP
|
|
||||||
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=/opt/pihole/whitelist.sh
|
whitelistScript=/opt/pihole/whitelist.sh
|
||||||
blacklistScript=/opt/pihole/blacklist.sh
|
blacklistScript=/opt/pihole/blacklist.sh
|
||||||
|
|
||||||
if [[ -f $piholeIPfile ]];then
|
#Source the setupVars from install script for the IP
|
||||||
# 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
|
setupVars=/etc/pihole/setupVars.conf
|
||||||
piholeIP=$(cat $piholeIPfile)
|
if [[ -f ${setupVars} ]];then
|
||||||
#rm $piholeIPfile
|
. /etc/pihole/setupVars.conf
|
||||||
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
|
echo "::: WARNING: /etc/pihole/setupVars.conf missing. Possible installation failure."
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
echo "::: Please run 'pihole -r', and choose the 'reconfigure' option to reconfigure."
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
exit 1
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
#Remove the /* from the end of the IPv4addr.
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
IPv4addr=${IPv4_address%/*}
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
|
||||||
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
|
|
||||||
#whitelist=$piholeDir/whitelist.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
|
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
if [[ -r ${piholeDir}/pihole.conf ]];then
|
||||||
echo "::: Local calibration requested..."
|
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
||||||
. $piholeDir/pihole.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# collapse - begin formation of pihole
|
# collapse - begin formation of pihole
|
||||||
function gravity_collapse() {
|
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 -r line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
else
|
else
|
||||||
sources+=($line)
|
sources+=(${line})
|
||||||
fi
|
fi
|
||||||
done < $adListFile
|
done < ${adListFile}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
#no custom file found, use defaults!
|
#no custom file found, use defaults!
|
||||||
@@ -97,32 +84,32 @@ function gravity_collapse() {
|
|||||||
sources=()
|
sources=()
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
else
|
else
|
||||||
sources+=($line)
|
sources+=(${line})
|
||||||
fi
|
fi
|
||||||
done < $adListDefault
|
done < ${adListDefault}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
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
|
chmod 777 ${piholeDir}
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Existing pihole directory found"
|
echo "::: Existing pihole directory found"
|
||||||
else
|
else
|
||||||
echo "::: Creating pihole directory..."
|
echo "::: Creating pihole directory..."
|
||||||
mkdir $piholeDir
|
mkdir ${piholeDir}
|
||||||
$SUDO chmod 777 $piholeDir
|
chmod 777 ${piholeDir}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# patternCheck - check to see if curl downloaded any new files.
|
# patternCheck - check to see if curl downloaded any new files.
|
||||||
function gravity_patternCheck() {
|
gravity_patternCheck() {
|
||||||
patternBuffer=$1
|
patternBuffer=$1
|
||||||
# check if the patternbuffer is a non-zero length file
|
# check if the patternbuffer is a non-zero length file
|
||||||
if [[ -s "$patternBuffer" ]];then
|
if [[ -s "$patternBuffer" ]];then
|
||||||
@@ -138,7 +125,7 @@ function gravity_patternCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# transport - curl the specified url with any needed command extentions
|
# transport - curl the specified url with any needed command extentions
|
||||||
function gravity_transport() {
|
gravity_transport() {
|
||||||
url=$1
|
url=$1
|
||||||
cmd_ext=$2
|
cmd_ext=$2
|
||||||
agent=$3
|
agent=$3
|
||||||
@@ -146,13 +133,13 @@ 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 -L $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
|
||||||
@@ -160,7 +147,7 @@ function gravity_transport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# spinup - main gravity function
|
# spinup - main gravity function
|
||||||
function gravity_spinup() {
|
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++))
|
||||||
@@ -170,8 +157,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"
|
||||||
|
|
||||||
@@ -197,29 +184,29 @@ 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() {
|
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
|
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(){
|
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
|
${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() {
|
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
|
||||||
@@ -229,50 +216,56 @@ function gravity_Whitelist() {
|
|||||||
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
|
${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() {
|
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
|
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() {
|
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..."
|
||||||
hostname=$(</etc/hostname)
|
if [[ -f /etc/hostname ]]; then
|
||||||
|
hostname=$(</etc/hostname)
|
||||||
|
elif [ -x "$(command -v hostname)" ]; then
|
||||||
|
hostname=$(hostname -f)
|
||||||
|
else
|
||||||
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
|
fi
|
||||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n "${IPv6_address}" ]];then
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||||
echo -e "$piholeIP $hostname\n$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc
|
echo -e "$IPv4addr $hostname\n$IPv6_address $hostname\n$IPv4addr pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$IPv6_address" '{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 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)
|
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||||
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc
|
echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" '{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() {
|
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
|
||||||
@@ -283,26 +276,29 @@ function gravity_blackbody() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_advanced() {
|
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
|
#awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
|
||||||
|
#Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment')
|
||||||
|
#Add additional awk command to read all lines up to a '#', and then continue as we were
|
||||||
|
cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | 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() {
|
gravity_reload() {
|
||||||
#Clear no longer needed files...
|
#Clear no longer needed files...
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Cleaning up un-needed files..."
|
echo -n "::: Cleaning up un-needed files..."
|
||||||
$SUDO rm $piholeDir/pihole.*.txt
|
rm ${piholeDir}/pihole.*.txt
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
@@ -313,22 +309,45 @@ function gravity_reload() {
|
|||||||
#First escape forward slashes in the path:
|
#First escape forward slashes in the path:
|
||||||
adList=${adList//\//\\\/}
|
adList=${adList//\//\\\/}
|
||||||
#Now replace the line in dnsmasq file
|
#Now replace the line in dnsmasq file
|
||||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
find "$piholeDir" -type f -exec chmod 666 {} \;
|
||||||
|
|
||||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \;
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
$SUDO killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
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
|
||||||
|
|
||||||
|
if [[ ${forceGrav} == true ]]; then
|
||||||
|
echo -n "::: Deleting exising list cache..."
|
||||||
|
rm /etc/pihole/list.*
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
|
||||||
|
cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
|
|||||||
230
pihole
230
pihole
@@ -12,90 +12,177 @@
|
|||||||
|
|
||||||
# Must be root to use this tool
|
# Must be root to use this tool
|
||||||
if [[ ! $EUID -eq 0 ]];then
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
#echo "::: You are root."
|
if [ -x "$(command -v sudo)" ];then
|
||||||
#else
|
echo "::: Elevating to root with sudo"
|
||||||
#echo "::: Sudo will be used for this tool."
|
exec sudo bash "$0" "$@"
|
||||||
# Check if it is actually installed
|
exit $?
|
||||||
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
else
|
||||||
if [ -x "$(command -v sudo)" ];then
|
echo "::: sudo is needed to run pihole commands. Please run this script as root or install sudo."
|
||||||
export SUDO="sudo"
|
exit 1
|
||||||
else
|
fi
|
||||||
echo "::: Please install sudo or run this as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function whitelistFunc {
|
whitelistFunc() {
|
||||||
shift
|
shift
|
||||||
$SUDO /opt/pihole/whitelist.sh "$@"
|
/opt/pihole/whitelist.sh "$@"
|
||||||
exit 1
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function blacklistFunc {
|
blacklistFunc() {
|
||||||
shift
|
shift
|
||||||
$SUDO /opt/pihole/blacklist.sh "$@"
|
/opt/pihole/blacklist.sh "$@"
|
||||||
exit 1
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugFunc {
|
debugFunc() {
|
||||||
$SUDO /opt/pihole/piholeDebug.sh
|
/opt/pihole/piholeDebug.sh
|
||||||
exit 1
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushFunc {
|
flushFunc() {
|
||||||
$SUDO /opt/pihole/piholeLogFlush.sh
|
/opt/pihole/piholeLogFlush.sh
|
||||||
exit 1
|
exit 0
|
||||||
}
|
|
||||||
|
|
||||||
function updateDashboardFunc {
|
|
||||||
$SUDO /opt/pihole/updateDashboard.sh
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateGravityFunc {
|
|
||||||
$SUDO /opt/pihole/gravity.sh
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupLCDFunction {
|
|
||||||
$SUDO /opt/pihole/setupLCD.sh
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function chronometerFunc {
|
|
||||||
shift
|
|
||||||
$SUDO /opt/pihole/chronometer.sh "$@"
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function uninstallFunc {
|
updatePiholeFunc() {
|
||||||
$SUDO /opt/pihole/uninstall.sh
|
|
||||||
exit 1
|
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
||||||
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||||
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
|
||||||
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||||
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::: Checking for updates..."
|
||||||
|
piholeVersion=$(cd /etc/.pihole/ && 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/",$//')
|
||||||
|
|
||||||
|
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||||
|
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)"
|
||||||
|
echo ":::"
|
||||||
|
|
||||||
|
if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then
|
||||||
|
echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}"
|
||||||
|
echo "::: No need to update!"
|
||||||
|
echo ":::"
|
||||||
|
|
||||||
|
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
|
||||||
|
echo "::: Web Admin files are already up to date!"
|
||||||
|
echo "::: No need to update!"
|
||||||
|
echo ":::"
|
||||||
|
else
|
||||||
|
echo "::: An Update is available for the Web Admin!"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Fetching latest changes from GitHub..."
|
||||||
|
cd /var/www/html/admin
|
||||||
|
git pull origin master
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Pi-hole Web Admin has been updated to ${webVersion}"
|
||||||
|
echo "::: See https://changes.pi-hole.net for details"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -n "::: An update is available for "
|
||||||
|
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
|
||||||
|
echo " Pi-Hole!"
|
||||||
|
else
|
||||||
|
echo " Pi-Hole base files and the Web Admin. Both will be updated!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::: Fetching latest changes from GitHub..."
|
||||||
|
cd /etc/.pihole
|
||||||
|
git pull origin master
|
||||||
|
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
||||||
|
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Pi-hole has been updated to version ${piholeVersionLatest}"
|
||||||
|
if [[ ${webVersion} != ${webVersionLatest} ]] ; then
|
||||||
|
echo "::: Web Admin has been updated to version ${webVersionLatest}"
|
||||||
|
fi
|
||||||
|
echo ":::"
|
||||||
|
echo "::: See https://changes.pi-hole.net for details"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function helpFunc {
|
reconfigurePiholeFunc() {
|
||||||
echo "::: Control all PiHole specific functions!"
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure
|
||||||
echo ":::"
|
exit 0;
|
||||||
echo "::: Usage: pihole [options]"
|
}
|
||||||
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
|
|
||||||
echo ":::"
|
updateGravityFunc() {
|
||||||
echo "::: Options:"
|
/opt/pihole/gravity.sh "$@"
|
||||||
echo "::: -w, whitelist Whitelist domains"
|
exit 0
|
||||||
echo "::: -b, blacklist Blacklist domains"
|
}
|
||||||
echo "::: -d, debug Start a debugging session if having trouble"
|
|
||||||
echo "::: -f, flush Flush the pihole.log file"
|
setupLCDFunction() {
|
||||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
/opt/pihole/setupLCD.sh
|
||||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
exit 0
|
||||||
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"
|
queryFunc() {
|
||||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
domain=$2
|
||||||
exit 1
|
for list in /etc/pihole/list.*
|
||||||
|
do
|
||||||
|
count=$(grep ${domain} $list | wc -l)
|
||||||
|
echo "::: ${list} (${count} results)"
|
||||||
|
if [[ ${count} > 0 ]]; then
|
||||||
|
grep ${domain} ${list}
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
chronometerFunc() {
|
||||||
|
shift
|
||||||
|
/opt/pihole/chronometer.sh "$@"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uninstallFunc() {
|
||||||
|
/opt/pihole/uninstall.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
versionFunc() {
|
||||||
|
/opt/pihole/version.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "::: -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 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle redirecting to specific functions based on arguments
|
# Handle redirecting to specific functions based on arguments
|
||||||
@@ -104,11 +191,14 @@ case "$1" in
|
|||||||
"-b" | "blacklist" ) blacklistFunc "$@";;
|
"-b" | "blacklist" ) blacklistFunc "$@";;
|
||||||
"-d" | "debug" ) debugFunc;;
|
"-d" | "debug" ) debugFunc;;
|
||||||
"-f" | "flush" ) flushFunc;;
|
"-f" | "flush" ) flushFunc;;
|
||||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
||||||
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
"-h" | "help" ) helpFunc;;
|
"-h" | "help" ) helpFunc;;
|
||||||
|
"-v" | "version" ) versionFunc;;
|
||||||
|
"-q" | "query" ) queryFunc "$@";;
|
||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user