Compare commits
30 Commits
2.8
...
v2.9-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84b54065ff | ||
|
|
f8edc810ff | ||
|
|
c9b461a2f8 | ||
|
|
e60490b4ed | ||
|
|
0ba6e59888 | ||
|
|
0dd5970f49 | ||
|
|
f73360e791 | ||
|
|
0d5600c21d | ||
|
|
c78c619cfb | ||
|
|
6469586a67 | ||
|
|
42614f6a7a | ||
|
|
aac7fa9c14 | ||
|
|
4b1633eac4 | ||
|
|
86d7eada79 | ||
|
|
a70c3bac61 | ||
|
|
67834062bc | ||
|
|
5b0e73c9f3 | ||
|
|
f671eef3f0 | ||
|
|
5ab54012d5 | ||
|
|
a04b7c4e99 | ||
|
|
e4ce5e3601 | ||
|
|
06f1aea319 | ||
|
|
2ab6746d53 | ||
|
|
253dfdf084 | ||
|
|
cec727be9d | ||
|
|
1d9531ef70 | ||
|
|
fbc400c67e | ||
|
|
0e59cf0fd1 | ||
|
|
96bacc372a | ||
|
|
6daf80ef56 |
119
README.md
119
README.md
@@ -1,9 +1,12 @@
|
|||||||
# Automated Install
|
# Automated Install
|
||||||
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
||||||
|
|
||||||
|
|
||||||
|
[](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
1. Install Raspbian
|
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!)
|
2. Run the command below
|
||||||
|
|
||||||
### ```curl -L https://install.pi-hole.net | bash```
|
### ```curl -L https://install.pi-hole.net | bash```
|
||||||
|
|
||||||
@@ -13,73 +16,21 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
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
|
## Pi-hole Is Free, But Powered By Your Donations
|
||||||
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
|
||||||
|
|
||||||
[](https://www.youtube.com/watch?v=TzFLJqUeirA)
|
## Catch us out on the net:
|
||||||
|
Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
||||||
|
|
||||||
|
reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
||||||
|
|
||||||
## How Does It Work?
|
## How Does It Work?
|
||||||
**Watch the 60-second video below to get a quick overview**
|
**Watch the 60-second video below to get a quick overview**
|
||||||
|
|
||||||
[](https://youtu.be/9Eti3xibiho)
|
[](https://vimeo.com/135965232)
|
||||||
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
|
|
||||||
## Get Help Or Connect With Us On The Web
|
|
||||||
|
|
||||||
- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
|
||||||
- [/r/pihole](https://www.reddit.com/r/pihole/)
|
|
||||||
- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
|
|
||||||
- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization)
|
|
||||||
- [FAQs](https://pi-hole.net/help/)
|
|
||||||
- [](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
||||||
|
|
||||||
## Technical Details
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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`
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Whitelist and blacklist
|
|
||||||
|
|
||||||
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
|
||||||

|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
|
||||||
```JSON
|
|
||||||
{
|
|
||||||
"domains_being_blocked": "136708",
|
|
||||||
"dns_queries_today": "18108",
|
|
||||||
"ads_blocked_today": "14648",
|
|
||||||
"ads_percentage_today": "80.89"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
The same output can be acheived on the CLI by running `chronometer.sh -j`
|
|
||||||
|
|
||||||
## Real-time Statistics
|
|
||||||
|
|
||||||
You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/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)
|
- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||||
@@ -96,7 +47,6 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-
|
|||||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
||||||
|
|
||||||
## 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)
|
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
|
||||||
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
|
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
|
||||||
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
|
- [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)
|
||||||
@@ -110,5 +60,52 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-
|
|||||||
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
- [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/)
|
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
||||||
|
|
||||||
|
## Partnering With Optimal.com
|
||||||
|
|
||||||
|
Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/).
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0).
|
||||||
|
|
||||||
|
## Gravity
|
||||||
|
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
|
||||||
|
|
||||||
|
## Whitelist and blacklist
|
||||||
|
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
||||||
|
|
||||||
|
## Web Interface
|
||||||
|
The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
|
||||||
|
|
||||||
|
`http://192.168.1.x/admin/index.php`
|
||||||
|
|
||||||
|

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

|
||||||
|
|
||||||
|
## Real-time Statistics
|
||||||
|
|
||||||
|
You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh).
|
||||||
|

|
||||||
|
|
||||||
|
## Help
|
||||||
|
- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details
|
||||||
|
- There is also an [FAQ section on pi-hole.net](http://pi-hole.net)
|
||||||
|
|
||||||
## Other Operating Systems
|
## 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.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
## Pi-hole ad-list default sources. Updated 22/05/2016 #########################
|
## Pi-hole ad-list default sources. Updated 21/02/2016 #########################
|
||||||
# #
|
# #
|
||||||
# To make changes to this file: #
|
# To make changes to this file: #
|
||||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||||
# 2. run `nano /etc/pihole/adlists.list` #
|
# 2. run `nano /etc/pihole/adlists.list` #
|
||||||
# 3. Uncomment or comment any of the below lists #
|
# 3. Uncomment or comment any of the below lists #
|
||||||
# #
|
# #
|
||||||
@@ -22,7 +22,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
|||||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||||
|
|
||||||
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||||
https://hosts-file.net/ad_servers.txt
|
http://hosts-file.net/ad_servers.txt
|
||||||
|
|
||||||
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
||||||
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
||||||
@@ -32,7 +32,7 @@ https://hosts-file.net/ad_servers.txt
|
|||||||
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||||
|
|
||||||
# Windows 10 telemetry list
|
# Windows 10 telemetry list
|
||||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt
|
||||||
|
|
||||||
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||||
#http://securemecca.com/Downloads/hosts.txt
|
#http://securemecca.com/Downloads/hosts.txt
|
||||||
@@ -43,15 +43,11 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
|||||||
# Block the BBC News website Breaking News banner
|
# Block the BBC News website Breaking News banner
|
||||||
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
||||||
|
|
||||||
# List of known C&C malware servers (see https://github.com/pi-hole/pi-hole/issues/528)
|
|
||||||
https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt
|
|
||||||
|
|
||||||
# Untested Lists:
|
# Untested Lists:
|
||||||
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||||
#https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt
|
#http://spam404bl.com/spam404scamlist.txt
|
||||||
#http://malwaredomains.lehigh.edu/files/domains.txt
|
#http://malwaredomains.lehigh.edu/files/domains.txt
|
||||||
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
|
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
|
||||||
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
||||||
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
||||||
# Combination of serveral host files on the internet (warning some facebook domains are also blocked but you can go to facebook.com). See https://github.com/mat1th/Dns-add-block for more information.
|
|
||||||
#https://raw.githubusercontent.com/mat1th/Dns-add-block/master/hosts
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ else
|
|||||||
echo "::: sudo will be used."
|
echo "::: sudo will be used."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this script as root."
|
echo "::: Please install sudo or run this script as root."
|
||||||
@@ -25,22 +25,6 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function helpFunc()
|
|
||||||
{
|
|
||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
|
||||||
echo ":::"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
|
||||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
echo "::: -h, --help Show this help dialog"
|
|
||||||
echo "::: -l, --list Display your blacklisted domains"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
@@ -86,6 +70,27 @@ if [[ -f $piholeIPv6file ]];then
|
|||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
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 helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||||
|
echo "::: Options:"
|
||||||
|
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||||
|
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||||
|
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||||
|
echo "::: -q, --quiet output is less verbose"
|
||||||
|
echo "::: -h, --help Show this help dialog"
|
||||||
|
echo "::: -l, --list Display your blacklisted domains"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# = 0 ]]; then
|
||||||
|
helpFunc
|
||||||
|
fi
|
||||||
|
|
||||||
function HandleOther(){
|
function HandleOther(){
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ if [[ $EUID -eq 0 ]]; then
|
|||||||
else
|
else
|
||||||
echo "::: Sudo will be used for debugging."
|
echo "::: Sudo will be used for debugging."
|
||||||
# Check if sudo is actually installed
|
# Check if sudo is actually installed
|
||||||
if [ -x "$(command -v sudo)" ]; then
|
if [[ $(dpkg-query -s sudo) ]]; then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
@@ -67,14 +67,6 @@ function versionCheck {
|
|||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
function distroCheck {
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "######## Distribution Section #########" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
|
|
||||||
TMP=$(cat /etc/*release/ || echo "Failed to find release")
|
|
||||||
echo "Distribution Version: $TMP" >> $DEBUG_LOG
|
|
||||||
|
|
||||||
function compareWhitelist {
|
function compareWhitelist {
|
||||||
if [ ! -f "$WHITELISTMATCHES" ]; then
|
if [ ! -f "$WHITELISTMATCHES" ]; then
|
||||||
$SUDO touch $WHITELISTMATCHES
|
$SUDO touch $WHITELISTMATCHES
|
||||||
@@ -203,7 +195,6 @@ echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
|||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
|
|
||||||
versionCheck
|
versionCheck
|
||||||
distroCheck
|
|
||||||
compareWhitelist
|
compareWhitelist
|
||||||
compareBlacklist
|
compareBlacklist
|
||||||
testNslookup
|
testNslookup
|
||||||
@@ -339,16 +330,8 @@ function dumpPiHoleLog {
|
|||||||
|
|
||||||
# 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 "::: Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
|
|
||||||
# Check if termbin.com is reachable. When it's not, point to local log instead
|
|
||||||
if [ -n "$TERMBIN" ]
|
|
||||||
then
|
|
||||||
echo "::: Debug log can be found at : $TERMBIN"
|
|
||||||
else
|
|
||||||
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ else
|
|||||||
echo "::: sudo will be used."
|
echo "::: sudo will be used."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this script as root."
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
|||||||
32
advanced/Scripts/updatePihole.sh
Normal file
32
advanced/Scripts/updatePihole.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/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
|
||||||
|
# Checks if Pi-hole needs updating and then
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Taken from http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
|
||||||
|
|
||||||
|
# Move into the git directory
|
||||||
|
cd /etc/.pihole/
|
||||||
|
|
||||||
|
LOCAL=$(git rev-parse @)
|
||||||
|
REMOTE=$(git rev-parse @{u})
|
||||||
|
BASE=$(git merge-base @ @{u})
|
||||||
|
|
||||||
|
if [[ $LOCAL = $REMOTE ]]; then
|
||||||
|
echo "Up-to-date"
|
||||||
|
elif [[ $LOCAL = $BASE ]]; then
|
||||||
|
echo "Updating Pi-hole..."
|
||||||
|
git pull
|
||||||
|
/opt/pihole/updatePiholeSecondary.sh
|
||||||
|
elif [[ $REMOTE = $BASE ]]; then
|
||||||
|
: # Need to push, so do nothing
|
||||||
|
else
|
||||||
|
: # Diverged, so do nothing
|
||||||
|
fi
|
||||||
103
advanced/Scripts/updatePiholeSecondary.sh
Normal file
103
advanced/Scripts/updatePiholeSecondary.sh
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#!/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
|
||||||
|
# Checks if Pi-hole needs updating and then
|
||||||
|
#
|
||||||
|
# Pi-hole is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Must be root to use this tool
|
||||||
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
|
#echo "::: You are root."
|
||||||
|
#else
|
||||||
|
#echo "::: Sudo will be used for this tool."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
function updateDependencies(){
|
||||||
|
#Add any new dependencies to the below array`
|
||||||
|
newDependencies=()
|
||||||
|
echo "::: Installing any new dependencies..."
|
||||||
|
for i in "${newDependencies[@]}"; do
|
||||||
|
echo "checking for $i"
|
||||||
|
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||||
|
echo -n " Not found! Installing...."
|
||||||
|
$SUDO apt-get -y -qq install "$i" > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo " already installed!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stopServices() {
|
||||||
|
# Stop dnsmasq and lighttpd
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Stopping services..."
|
||||||
|
$SUDO service lighttpd stop
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
installScripts() {
|
||||||
|
# Install the scripts from /etc/.pihole to their various locations
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Updating scripts in /opt/pihole..."
|
||||||
|
|
||||||
|
$SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePihole.sh /opt/pihole/updatePihole.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePiholeSecondary.sh /opt/pihole/updatePiholeSecondary.sh
|
||||||
|
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
||||||
|
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,updatePihole,updatePiholeSecondary,uninstall,setupLCD, piholeDebug}.sh
|
||||||
|
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
||||||
|
$SUDO chmod 755 /usr/local/bin/pihole
|
||||||
|
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
|
. /etc/bash_completion.d/pihole
|
||||||
|
|
||||||
|
#Tidy up /usr/local/bin directory if updating an old installation (can probably be removed at some point)
|
||||||
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard updatePihole updatePiholeSecondary uninstall setupLCD piholeDebug)
|
||||||
|
for i in "${oldFiles[@]}"; do
|
||||||
|
if [ -f "/usr/local/bin/$i.sh" ]; then
|
||||||
|
$SUDO rm /usr/local/bin/"$i".sh
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
# SCRIPT STARTS HERE! #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
#uncomment the below if adding new dependencies (don't forget to update the install script!)
|
||||||
|
#updateDependencies
|
||||||
|
stopServices
|
||||||
|
installScripts
|
||||||
|
|
||||||
|
#TODO:
|
||||||
|
# - Distribute files`
|
||||||
|
# - Run pihole -g
|
||||||
|
# - add root check, maybe? Do we need to? Probably a good idea.
|
||||||
|
# - update install script to populate a config file with:
|
||||||
|
# -IPv4
|
||||||
|
# -IPv6
|
||||||
|
# -UpstreamDNS servers
|
||||||
@@ -17,7 +17,7 @@ else
|
|||||||
echo "::: sudo will be used."
|
echo "::: sudo will be used."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this script as root."
|
echo "::: Please install sudo or run this script as root."
|
||||||
@@ -25,22 +25,6 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function helpFunc()
|
|
||||||
{
|
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
|
||||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
echo "::: -h, --help Show this help dialog"
|
|
||||||
echo "::: -l, --list Display your whitelisted domains"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
@@ -85,6 +69,27 @@ if [[ -f $piholeIPv6file ]];then
|
|||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
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 helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Options:"
|
||||||
|
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||||
|
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||||
|
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||||
|
echo "::: -q, --quiet output is less verbose"
|
||||||
|
echo "::: -h, --help Show this help dialog"
|
||||||
|
echo "::: -l, --list Display your whitelisted domains"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# = 0 ]]; then
|
||||||
|
helpFunc
|
||||||
|
fi
|
||||||
|
|
||||||
function HandleOther(){
|
function HandleOther(){
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ server.modules = (
|
|||||||
"mod_accesslog",
|
"mod_accesslog",
|
||||||
"mod_expire",
|
"mod_expire",
|
||||||
"mod_compress",
|
"mod_compress",
|
||||||
"mod_redirect",
|
"mod_redirect",
|
||||||
"mod_setenv",
|
"mod_setenv",
|
||||||
"mod_rewrite"
|
"mod_rewrite"
|
||||||
)
|
)
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# lighttpd config for Pi-hole
|
|
||||||
#
|
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
server.modules = (
|
|
||||||
"mod_access",
|
|
||||||
"mod_fastcgi",
|
|
||||||
"mod_accesslog",
|
|
||||||
"mod_expire",
|
|
||||||
"mod_compress",
|
|
||||||
"mod_redirect",
|
|
||||||
"mod_setenv",
|
|
||||||
"mod_rewrite"
|
|
||||||
)
|
|
||||||
|
|
||||||
server.document-root = "/var/www/html"
|
|
||||||
server.error-handler-404 = "pihole/index.html"
|
|
||||||
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
|
|
||||||
server.errorlog = "/var/log/lighttpd/error.log"
|
|
||||||
server.pid-file = "/var/run/lighttpd.pid"
|
|
||||||
server.username = "lighttpd"
|
|
||||||
server.groupname = "lighttpd"
|
|
||||||
server.port = 80
|
|
||||||
accesslog.filename = "/var/log/lighttpd/access.log"
|
|
||||||
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
|
||||||
|
|
||||||
|
|
||||||
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
|
|
||||||
url.access-deny = ( "~", ".inc" )
|
|
||||||
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
|
|
||||||
|
|
||||||
compress.cache-dir = "/var/cache/lighttpd/compress/"
|
|
||||||
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
|
|
||||||
|
|
||||||
mimetype.assign = ( ".png" => "image/png",
|
|
||||||
".jpg" => "image/jpeg",
|
|
||||||
".jpeg" => "image/jpeg",
|
|
||||||
".html" => "text/html",
|
|
||||||
".css" => "text/css; charset=utf-8",
|
|
||||||
".js" => "application/javascript",
|
|
||||||
".json" => "application/json",
|
|
||||||
".txt" => "text/plain" )
|
|
||||||
|
|
||||||
# default listening port for IPv6 falls back to the IPv4 port
|
|
||||||
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
|
|
||||||
#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
|
|
||||||
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
|
||||||
|
|
||||||
fastcgi.server = ( ".php" =>
|
|
||||||
( "localhost" =>
|
|
||||||
(
|
|
||||||
"socket" => "/tmp/php-fastcgi.socket",
|
|
||||||
"bin-path" => "/usr/bin/php-cgi"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# If the URL starts with /admin, it is the Web interface
|
|
||||||
$HTTP["url"] =~ "^/admin/" {
|
|
||||||
# Create a response header for debugging using curl -I
|
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
|
||||||
}
|
|
||||||
|
|
||||||
# If the URL does not start with /admin, then it is a query for an ad domain
|
|
||||||
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
|
||||||
# Create a response header for debugging using curl -I
|
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
|
||||||
# rewrite only js requests
|
|
||||||
url.rewrite = ("(.*).js" => "pihole/index.js")
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
# Pi-hole: Check if Pi-hole needs to be updated. Check once a week on Monday at 23:58
|
||||||
|
# New releases often come out on Sunday, so checking the next day should be effective.
|
||||||
|
#23 58 * * 1 root /usr/local/bin/updatePihole
|
||||||
|
|
||||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||||
# Download any updates from the 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
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# Allows the WebUI to use Pi-hole commands
|
|
||||||
#
|
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
www-data ALL=NOPASSWD: /usr/local/bin/pihole
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
module pihole 1.0;
|
|
||||||
|
|
||||||
require {
|
|
||||||
type var_log_t;
|
|
||||||
type unconfined_t;
|
|
||||||
type init_t;
|
|
||||||
type auditd_t;
|
|
||||||
type syslogd_t;
|
|
||||||
type NetworkManager_t;
|
|
||||||
type mdadm_t;
|
|
||||||
type tuned_t;
|
|
||||||
type avahi_t;
|
|
||||||
type irqbalance_t;
|
|
||||||
type system_dbusd_t;
|
|
||||||
type kernel_t;
|
|
||||||
type httpd_sys_script_t;
|
|
||||||
type systemd_logind_t;
|
|
||||||
type httpd_t;
|
|
||||||
type policykit_t;
|
|
||||||
type dnsmasq_t;
|
|
||||||
type udev_t;
|
|
||||||
type postfix_pickup_t;
|
|
||||||
type sshd_t;
|
|
||||||
type crond_t;
|
|
||||||
type getty_t;
|
|
||||||
type lvm_t;
|
|
||||||
type postfix_qmgr_t;
|
|
||||||
type postfix_master_t;
|
|
||||||
class dir { getattr search };
|
|
||||||
class file { read open setattr };
|
|
||||||
}
|
|
||||||
|
|
||||||
#============= dnsmasq_t ==============
|
|
||||||
allow dnsmasq_t var_log_t:file { open setattr };
|
|
||||||
|
|
||||||
#============= httpd_t ==============
|
|
||||||
allow httpd_t var_log_t:file { read open };
|
|
||||||
|
|
||||||
#============= httpd_sys_script_t (class: dir) ==============
|
|
||||||
allow httpd_sys_script_t NetworkManager_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t auditd_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t avahi_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t crond_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t dnsmasq_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t getty_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t httpd_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t init_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t irqbalance_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t kernel_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t lvm_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t mdadm_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t policykit_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t postfix_master_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t postfix_pickup_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t postfix_qmgr_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t sshd_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t syslogd_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t system_dbusd_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t systemd_logind_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t tuned_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t udev_t:dir { getattr search };
|
|
||||||
allow httpd_sys_script_t unconfined_t:dir { getattr search };
|
|
||||||
|
|
||||||
#============= httpd_sys_script_t (class: file) ==============
|
|
||||||
allow httpd_sys_script_t NetworkManager_t:file { read open };
|
|
||||||
allow httpd_sys_script_t auditd_t:file { read open };
|
|
||||||
allow httpd_sys_script_t avahi_t:file { read open };
|
|
||||||
allow httpd_sys_script_t crond_t:file { read open };
|
|
||||||
allow httpd_sys_script_t dnsmasq_t:file { read open };
|
|
||||||
allow httpd_sys_script_t getty_t:file { read open };
|
|
||||||
allow httpd_sys_script_t httpd_t:file { read open };
|
|
||||||
allow httpd_sys_script_t init_t:file { read open };
|
|
||||||
allow httpd_sys_script_t irqbalance_t:file { read open };
|
|
||||||
allow httpd_sys_script_t kernel_t:file { read open };
|
|
||||||
allow httpd_sys_script_t lvm_t:file { read open };
|
|
||||||
allow httpd_sys_script_t mdadm_t:file { read open };
|
|
||||||
allow httpd_sys_script_t policykit_t:file { read open };
|
|
||||||
allow httpd_sys_script_t postfix_master_t:file { read open };
|
|
||||||
allow httpd_sys_script_t postfix_pickup_t:file { read open };
|
|
||||||
allow httpd_sys_script_t postfix_qmgr_t:file { read open };
|
|
||||||
allow httpd_sys_script_t sshd_t:file { read open };
|
|
||||||
allow httpd_sys_script_t syslogd_t:file { read open };
|
|
||||||
allow httpd_sys_script_t system_dbusd_t:file { read open };
|
|
||||||
allow httpd_sys_script_t systemd_logind_t:file { read open };
|
|
||||||
allow httpd_sys_script_t tuned_t:file { read open };
|
|
||||||
allow httpd_sys_script_t udev_t:file { read open };
|
|
||||||
allow httpd_sys_script_t unconfined_t:file { read open };
|
|
||||||
@@ -36,6 +36,16 @@ columns=$(tput cols)
|
|||||||
r=$(( rows / 2 ))
|
r=$(( rows / 2 ))
|
||||||
c=$(( columns / 2 ))
|
c=$(( columns / 2 ))
|
||||||
|
|
||||||
|
|
||||||
|
# Find IP used to route to outside world
|
||||||
|
|
||||||
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
|
IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
|
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
|
||||||
|
|
||||||
|
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1)
|
||||||
|
dhcpcdFile=/etc/dhcpcd.conf
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
# Must be root to install
|
# Must be root to install
|
||||||
echo ":::"
|
echo ":::"
|
||||||
@@ -45,55 +55,14 @@ else
|
|||||||
echo "::: sudo will be used for the install."
|
echo "::: sudo will be used for the install."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
echo "::: Please install sudo or run this as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compatability
|
|
||||||
if [ -x "$(command -v rpm)" ];then
|
|
||||||
# Fedora Family
|
|
||||||
if [ -x "$(command -v dnf)" ];then
|
|
||||||
PKG_MANAGER="dnf"
|
|
||||||
else
|
|
||||||
PKG_MANAGER="yum"
|
|
||||||
fi
|
|
||||||
PKG_CACHE="/var/cache/$PKG_MANAGER"
|
|
||||||
UPDATE_PKG_CACHE="$PKG_MANAGER check-update -q"
|
|
||||||
PKG_UPDATE="$PKG_MANAGER update -y"
|
|
||||||
PKG_INSTALL="$PKG_MANAGER install -y"
|
|
||||||
PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]"
|
|
||||||
INSTALLER_DEPS=( iproute net-tools procps-ng newt )
|
|
||||||
PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo netcat )
|
|
||||||
LIGHTTPD_USER="lighttpd"
|
|
||||||
LIGHTTPD_GROUP="lighttpd"
|
|
||||||
LIGHTTPD_CFG="lighttpd.conf.fedora"
|
|
||||||
package_check() {
|
|
||||||
rpm -qa | grep ^$1- > /dev/null
|
|
||||||
}
|
|
||||||
elif [ -x "$(command -v apt-get)" ];then
|
|
||||||
# Debian Family
|
|
||||||
PKG_MANAGER="apt-get"
|
|
||||||
PKG_CACHE="/var/cache/apt"
|
|
||||||
UPDATE_PKG_CACHE="$PKG_MANAGER -qq update"
|
|
||||||
PKG_UPDATE="$PKG_MANAGER upgrade"
|
|
||||||
PKG_INSTALL="$PKG_MANAGER --yes --quiet install"
|
|
||||||
PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst"
|
|
||||||
INSTALLER_DEPS=( apt-utils whiptail dhcpcd5)
|
|
||||||
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo netcat )
|
|
||||||
LIGHTTPD_USER="www-data"
|
|
||||||
LIGHTTPD_GROUP="www-data"
|
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
|
||||||
package_check() {
|
|
||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo "OS distribution not supported"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
spinner()
|
spinner()
|
||||||
@@ -111,14 +80,6 @@ spinner()
|
|||||||
printf " \b\b\b\b"
|
printf " \b\b\b\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
findIPRoute() {
|
|
||||||
# Find IP used to route to outside world
|
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
|
||||||
IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
|
||||||
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
|
|
||||||
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1)
|
|
||||||
}
|
|
||||||
|
|
||||||
backupLegacyPihole() {
|
backupLegacyPihole() {
|
||||||
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
|
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
|
||||||
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
||||||
@@ -149,7 +110,7 @@ welcomeDialogs() {
|
|||||||
|
|
||||||
# Explain the need for a static address
|
# Explain the need for a static address
|
||||||
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
||||||
|
|
||||||
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +236,7 @@ getStaticIPv4Settings() {
|
|||||||
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
|
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
|
||||||
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c
|
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c
|
||||||
#piholeIP is saved to a permanent file so gravity.sh can use it when updating
|
#piholeIP is saved to a permanent file so gravity.sh can use it when updating
|
||||||
$SUDO echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
||||||
# Nothing else to do since the variables are already set above
|
# Nothing else to do since the variables are already set above
|
||||||
else
|
else
|
||||||
# Otherwise, we need to ask the user to input their desired settings.
|
# Otherwise, we need to ask the user to input their desired settings.
|
||||||
@@ -297,8 +258,8 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
|
|||||||
Gateway: $IPv4gw" $r $c)then
|
Gateway: $IPv4gw" $r $c)then
|
||||||
# If the settings are correct, then we need to set the piholeIP
|
# If the settings are correct, then we need to set the piholeIP
|
||||||
# Saving it to a temporary file us to retrieve it later when we run the gravity.sh script. piholeIP is saved to a permanent file so gravity.sh can use it when updating
|
# Saving it to a temporary file us to retrieve it later when we run the gravity.sh script. piholeIP is saved to a permanent file so gravity.sh can use it when updating
|
||||||
$SUDO echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
||||||
$SUDO echo "$piholeInterface" > /tmp/piholeINT
|
echo "$piholeInterface" > /tmp/piholeINT
|
||||||
# After that's done, the loop ends and we move on
|
# After that's done, the loop ends and we move on
|
||||||
ipSettingsCorrect=True
|
ipSettingsCorrect=True
|
||||||
else
|
else
|
||||||
@@ -327,52 +288,20 @@ setDHCPCD() {
|
|||||||
echo "::: interface $piholeInterface
|
echo "::: interface $piholeInterface
|
||||||
static ip_address=$IPv4addr
|
static ip_address=$IPv4addr
|
||||||
static routers=$IPv4gw
|
static routers=$IPv4gw
|
||||||
static domain_name_servers=$IPv4gw" | $SUDO tee -a /etc/dhcpcd.conf >/dev/null
|
static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
setStaticIPv4() {
|
setStaticIPv4() {
|
||||||
if [[ -f /etc/dhcpcd.conf ]];then
|
# Tries to set the IPv4 address
|
||||||
# Debian Family
|
if grep -q "$IPv4addr" $dhcpcdFile; then
|
||||||
if grep -q "$IPv4addr" /etc/dhcpcd.conf; then
|
# address already set, noop
|
||||||
echo "::: Static IP already configured"
|
:
|
||||||
else
|
|
||||||
setDHCPCD
|
|
||||||
$SUDO ip addr replace dev "$piholeInterface" "$IPv4addr"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
|
||||||
echo ":::"
|
|
||||||
fi
|
|
||||||
elif [[ -f /etc/sysconfig/network-scripts/ifcfg-$piholeInterface ]];then
|
|
||||||
# Fedora Family
|
|
||||||
IFCFG_FILE=/etc/sysconfig/network-scripts/ifcfg-$piholeInterface
|
|
||||||
if grep -q "$IPv4addr" $IFCFG_FILE; then
|
|
||||||
echo "::: Static IP already configured"
|
|
||||||
else
|
|
||||||
IPADDR=$(echo $IPv4addr | cut -f1 -d/)
|
|
||||||
CIDR=$(echo $IPv4addr | cut -f2 -d/)
|
|
||||||
# Backup existing interface configuration:
|
|
||||||
cp $IFCFG_FILE $IFCFG_FILE.backup-$(date +%Y-%m-%d-%H%M%S)
|
|
||||||
# Build Interface configuration file:
|
|
||||||
$SUDO echo "# Configured via Pi-Hole installer" > $IFCFG_FILE
|
|
||||||
$SUDO echo "DEVICE=$piholeInterface" >> $IFCFG_FILE
|
|
||||||
$SUDO echo "BOOTPROTO=none" >> $IFCFG_FILE
|
|
||||||
$SUDO echo "ONBOOT=yes" >> $IFCFG_FILE
|
|
||||||
$SUDO echo "IPADDR=$IPADDR" >> $IFCFG_FILE
|
|
||||||
$SUDO echo "PREFIX=$CIDR" >> $IFCFG_FILE
|
|
||||||
$SUDO echo "USERCTL=no" >> $IFCFG_FILE
|
|
||||||
$SUDO ip addr replace dev "$piholeInterface" "$IPv4addr"
|
|
||||||
if [ -x "$(command -v nmcli)" ];then
|
|
||||||
# Tell NetworkManager to read our new sysconfig file
|
|
||||||
$SUDO nmcli con load $IFCFG_FILE > /dev/null
|
|
||||||
fi
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
|
||||||
echo ":::"
|
|
||||||
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "::: Warning: Unable to locate configuration file to set static IPv4 address!"
|
setDHCPCD
|
||||||
exit 1
|
$SUDO ip addr replace dev "$piholeInterface" "$IPv4addr"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
||||||
|
echo ":::"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,7 +455,6 @@ versionCheckDNSmasq(){
|
|||||||
else
|
else
|
||||||
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
||||||
fi
|
fi
|
||||||
$SUDO sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' $dnsFile1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts() {
|
installScripts() {
|
||||||
@@ -545,16 +473,18 @@ installScripts() {
|
|||||||
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePihole.sh /opt/pihole/updatePihole.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePiholeSecondary.sh /opt/pihole/updatePiholeSecondary.sh
|
||||||
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
||||||
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh
|
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,updatePihole,updatePiholeSecondary,uninstall,setupLCD, piholeDebug}.sh
|
||||||
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
||||||
$SUDO chmod 755 /usr/local/bin/pihole
|
$SUDO chmod 755 /usr/local/bin/pihole
|
||||||
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
. /etc/bash_completion.d/pihole
|
. /etc/bash_completion.d/pihole
|
||||||
|
|
||||||
#Tidy up /usr/local/bin directory if installing over previous install.
|
#Tidy up /usr/local/bin directory if installing over previous install.
|
||||||
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard updatePihole updatePiholeSecondary uninstall setupLCD piholeDebug)
|
||||||
for i in "${oldFiles[@]}"; do
|
for i in "${oldFiles[@]}"; do
|
||||||
if [ -f "/usr/local/bin/$i.sh" ]; then
|
if [ -f "/usr/local/bin/$i.sh" ]; then
|
||||||
$SUDO rm /usr/local/bin/"$i".sh
|
$SUDO rm /usr/local/bin/"$i".sh
|
||||||
@@ -574,11 +504,7 @@ installConfigs() {
|
|||||||
$SUDO chown "$USER":root /etc/lighttpd
|
$SUDO chown "$USER":root /etc/lighttpd
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
fi
|
fi
|
||||||
$SUDO cp /etc/.pihole/advanced/$LIGHTTPD_CFG /etc/lighttpd/lighttpd.conf
|
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||||
$SUDO mkdir -p /var/run/lighttpd
|
|
||||||
$SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/run/lighttpd
|
|
||||||
$SUDO mkdir -p /var/cache/lighttpd/compress
|
|
||||||
$SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/cache/lighttpd/compress
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices() {
|
stopServices() {
|
||||||
@@ -586,52 +512,50 @@ stopServices() {
|
|||||||
$SUDO echo ":::"
|
$SUDO echo ":::"
|
||||||
$SUDO echo -n "::: Stopping services..."
|
$SUDO echo -n "::: Stopping services..."
|
||||||
#$SUDO service dnsmasq stop & spinner $! || true
|
#$SUDO service dnsmasq stop & spinner $! || true
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
$SUDO service lighttpd stop & spinner $! || true
|
||||||
$SUDO systemctl stop lighttpd & spinner $! || true
|
|
||||||
else
|
|
||||||
$SUDO service lighttpd stop & spinner $! || true
|
|
||||||
fi
|
|
||||||
$SUDO echo " done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installerDependencies() {
|
checkForDependencies() {
|
||||||
#Running apt-get update/upgrade with minimal output can cause some issues with
|
#Running apt-get update/upgrade with minimal output can cause some issues with
|
||||||
#requiring user input (e.g password for phpmyadmin see #218)
|
#requiring user input (e.g password for phpmyadmin see #218)
|
||||||
#We'll change the logic up here, to check to see if there are any updates availible and
|
#We'll change the logic up here, to check to see if there are any updates availible and
|
||||||
# if so, advise the user to run apt-get update/upgrade at their own discretion
|
# if so, advise the user to run apt-get update/upgrade at their own discretion
|
||||||
#Check to see if apt-get update has already been run today
|
#Check to see if apt-get update has already been run today
|
||||||
# it needs to have been run at least once on new installs!
|
# it needs to have been run at least once on new installs!
|
||||||
timestamp=$(stat -c %Y $PKG_CACHE)
|
|
||||||
|
timestamp=$(stat -c %Y /var/cache/apt/)
|
||||||
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
if [ ! "$today" == "$timestampAsDate" ]; then
|
||||||
#update package lists
|
#update package lists
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: $PKG_MANAGER update has not been run today. Running now..."
|
echo -n "::: apt-get update has not been run today. Running now..."
|
||||||
$SUDO $UPDATE_PKG_CACHE > /dev/null 2>&1
|
$SUDO apt-get -qq update & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Checking $PKG_MANAGER for upgraded packages...."
|
echo -n "::: Checking apt-get for upgraded packages...."
|
||||||
updatesToInstall=$(eval "$SUDO $PKG_COUNT")
|
updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ $updatesToInstall -eq "0" ]]; then
|
if [[ $updatesToInstall -eq "0" ]]; then
|
||||||
echo "::: Your pi is up to date! Continuing with pi-hole installation..."
|
echo "::: Your pi is up to date! Continuing with pi-hole installation..."
|
||||||
else
|
else
|
||||||
echo "::: There are $updatesToInstall updates availible for your pi!"
|
echo "::: There are $updatesToInstall updates availible for your pi!"
|
||||||
echo "::: We recommend you run '$PKG_UPDATE' after installing Pi-Hole! "
|
echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! "
|
||||||
echo ":::"
|
echo ":::"
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking installer dependencies..."
|
echo "::: Checking dependencies:"
|
||||||
for i in "${INSTALLER_DEPS[@]}"; do
|
|
||||||
|
dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget )
|
||||||
|
for i in "${dependencies[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
package_check $i > /dev/null
|
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||||
if ! [ $? -eq 0 ]; then
|
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
$SUDO $PKG_INSTALL "$i" > /dev/null 2>&1
|
$SUDO apt-get -y -qq install "$i" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
@@ -639,23 +563,6 @@ installerDependencies() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForDependencies() {
|
|
||||||
# Install dependencies for Pi-Hole
|
|
||||||
echo "::: Checking Pi-Hole dependencies:"
|
|
||||||
|
|
||||||
for i in "${PIHOLE_DEPS[@]}"; do
|
|
||||||
echo -n "::: Checking for $i..."
|
|
||||||
package_check $i > /dev/null
|
|
||||||
if ! [ $? -eq 0 ]; then
|
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
$SUDO $PKG_INSTALL "$i" > /dev/null & spinner $!
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo " already installed!"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
getGitFiles() {
|
getGitFiles() {
|
||||||
# Setup git repos for base files and web admin
|
# Setup git repos for base files and web admin
|
||||||
echo ":::"
|
echo ":::"
|
||||||
@@ -733,12 +640,6 @@ installPiholeWeb() {
|
|||||||
$SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/.
|
$SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/.
|
||||||
$SUDO echo " done!"
|
$SUDO echo " done!"
|
||||||
fi
|
fi
|
||||||
# Install Sudoer file
|
|
||||||
echo -n "::: Installing sudoer file..."
|
|
||||||
$SUDO mkdir -p /etc/sudoers.d/
|
|
||||||
$SUDO cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole
|
|
||||||
$SUDO chmod 0440 /etc/sudoers.d/pihole
|
|
||||||
echo " done!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installCron() {
|
installCron() {
|
||||||
@@ -772,27 +673,6 @@ setUser(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFirewall() {
|
|
||||||
# Allow HTTP and DNS traffic
|
|
||||||
if [ -x "$(command -v firewall-cmd)" ]; then
|
|
||||||
$SUDO firewall-cmd --state > /dev/null
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
$SUDO echo "::: Configuring firewalld for httpd and dnsmasq.."
|
|
||||||
$SUDO firewall-cmd --permanent --add-port=80/tcp
|
|
||||||
$SUDO firewall-cmd --permanent --add-port=53/tcp
|
|
||||||
$SUDO firewall-cmd --permanent --add-port=53/udp
|
|
||||||
$SUDO firewall-cmd --reload
|
|
||||||
fi
|
|
||||||
elif [ -x "$(command -v iptables)" ]; then
|
|
||||||
$SUDO echo "::: Configuring iptables for httpd and dnsmasq.."
|
|
||||||
$SUDO iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
|
||||||
$SUDO iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
|
|
||||||
$SUDO iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT
|
|
||||||
else
|
|
||||||
$SUDO echo "::: No firewall detected.. skipping firewall configuration."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
installPihole() {
|
installPihole() {
|
||||||
# Install base files and web interface
|
# Install base files and web interface
|
||||||
checkForDependencies # done
|
checkForDependencies # done
|
||||||
@@ -802,77 +682,35 @@ installPihole() {
|
|||||||
if [ ! -d "/var/www/html" ]; then
|
if [ ! -d "/var/www/html" ]; then
|
||||||
$SUDO mkdir -p /var/www/html
|
$SUDO mkdir -p /var/www/html
|
||||||
fi
|
fi
|
||||||
$SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/www/html
|
$SUDO chown www-data:www-data /var/www/html
|
||||||
$SUDO chmod 775 /var/www/html
|
$SUDO chmod 775 /var/www/html
|
||||||
$SUDO usermod -a -G $LIGHTTPD_GROUP pihole
|
$SUDO usermod -a -G www-data pihole
|
||||||
if [ -x "$(command -v lighty-enable-mod)" ]; then
|
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
|
||||||
else
|
|
||||||
printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
getGitFiles
|
getGitFiles
|
||||||
installScripts
|
installScripts
|
||||||
installConfigs
|
installConfigs
|
||||||
CreateLogFile
|
CreateLogFile
|
||||||
configureSelinux
|
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
runGravity
|
runGravity
|
||||||
configureFirewall
|
|
||||||
}
|
|
||||||
|
|
||||||
configureSelinux() {
|
|
||||||
if [ -x "$(command -v getenforce)" ]; then
|
|
||||||
printf "\n::: SELinux Detected\n"
|
|
||||||
printf ":::\tChecking for SELinux policy development packages..."
|
|
||||||
package_check "selinux-policy-devel" > /dev/null
|
|
||||||
if ! [ $? -eq 0 ]; then
|
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
$SUDO $PKG_INSTALL "selinux-policy-devel" > /dev/null & spinner $!
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo " already installed!"
|
|
||||||
fi
|
|
||||||
printf "::: Enabling httpd server side includes (SSI).. "
|
|
||||||
$SUDO setsebool -P httpd_ssi_exec on
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo -n "Success\n"
|
|
||||||
fi
|
|
||||||
printf ":::\tCompiling Pi-Hole SELinux policy..\n"
|
|
||||||
$SUDO checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te
|
|
||||||
$SUDO semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod
|
|
||||||
$SUDO semodule -i /etc/pihole/pihole.pp
|
|
||||||
$SUDO rm -f /etc/pihole/pihole.mod
|
|
||||||
$SUDO semodule -l | grep pihole > /dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
printf "::: Successfully installed Pi-Hole SELinux policy\n"
|
|
||||||
else
|
|
||||||
printf "::: Warning: Pi-Hole SELinux policy did not install correctly!\n"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFinalMessage() {
|
displayFinalMessage() {
|
||||||
# Final completion message to user
|
# Final completion message to user
|
||||||
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
||||||
|
|
||||||
IPv4: ${IPv4addr%/*}
|
IPv4: $IPv4addr
|
||||||
IPv6: $piholeIPv6
|
IPv6: $piholeIPv6
|
||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
The install log is in /etc/pihole.
|
The install log is in /etc/pihole." $r $c
|
||||||
View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" $r $c
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######## SCRIPT ############
|
######## SCRIPT ############
|
||||||
# Start the installer
|
# Start the installer
|
||||||
$SUDO mkdir -p /etc/pihole/
|
$SUDO mkdir -p /etc/pihole/
|
||||||
|
|
||||||
# Install packages used by this installation script
|
|
||||||
installerDependencies
|
|
||||||
|
|
||||||
welcomeDialogs
|
welcomeDialogs
|
||||||
|
|
||||||
# Verify there is enough disk space for the install
|
# Verify there is enough disk space for the install
|
||||||
@@ -880,8 +718,6 @@ verifyFreeDiskSpace
|
|||||||
|
|
||||||
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
|
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
|
||||||
backupLegacyPihole
|
backupLegacyPihole
|
||||||
# Find IP used to route to outside world
|
|
||||||
findIPRoute
|
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
chooseInterface
|
chooseInterface
|
||||||
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
||||||
@@ -900,24 +736,16 @@ displayFinalMessage
|
|||||||
|
|
||||||
echo -n "::: Restarting services..."
|
echo -n "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
$SUDO service dnsmasq restart
|
||||||
$SUDO systemctl enable dnsmasq
|
$SUDO service lighttpd start
|
||||||
$SUDO systemctl restart dnsmasq
|
|
||||||
$SUDO systemctl enable lighttpd
|
|
||||||
$SUDO systemctl start lighttpd
|
|
||||||
else
|
|
||||||
$SUDO service dnsmasq restart
|
|
||||||
$SUDO service lighttpd start
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
||||||
echo "::: ${IPv4addr%/*}"
|
echo "::: $IPv4addr"
|
||||||
echo "::: $piholeIPv6"
|
echo "::: $piholeIPv6"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: If you set a new IP address, you should restart the Pi."
|
echo "::: If you set a new IP address, you should restart the Pi."
|
||||||
echo ":::"
|
echo "::: "
|
||||||
echo "::: The install log is located at: /etc/pihole/install.log"
|
echo "::: The install log is located at: /etc/pihole/install.log"
|
||||||
echo "::: View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin"
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ else
|
|||||||
echo "::: Sudo will be used for the uninstall."
|
echo "::: Sudo will be used for the uninstall."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the unnstall cannot complete
|
# If it isn't, exit because the unnstall cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
@@ -25,39 +25,6 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compatability
|
|
||||||
if [ -x "$(command -v rpm)" ];then
|
|
||||||
# Fedora Family
|
|
||||||
if [ -x "$(command -v dnf)" ];then
|
|
||||||
PKG_MANAGER="dnf"
|
|
||||||
else
|
|
||||||
PKG_MANAGER="yum"
|
|
||||||
fi
|
|
||||||
PKG_REMOVE="$PKG_MANAGER remove -y"
|
|
||||||
PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils )
|
|
||||||
package_check() {
|
|
||||||
rpm -qa | grep ^$1- > /dev/null
|
|
||||||
}
|
|
||||||
package_cleanup() {
|
|
||||||
$SUDO $PKG_MANAGER -y autoremove
|
|
||||||
}
|
|
||||||
elif [ -x "$(command -v apt-get)" ];then
|
|
||||||
# Debian Family
|
|
||||||
PKG_MANAGER="apt-get"
|
|
||||||
PKG_REMOVE="$PKG_MANAGER -y remove --purge"
|
|
||||||
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
|
|
||||||
package_check() {
|
|
||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
|
||||||
}
|
|
||||||
package_cleanup() {
|
|
||||||
$SUDO $PKG_MANAGER -y autoremove
|
|
||||||
$SUDO $PKG_MANAGER -y autoclean
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo "OS distribution not supported"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
spinner()
|
spinner()
|
||||||
{
|
{
|
||||||
local pid=$1
|
local pid=$1
|
||||||
@@ -76,13 +43,14 @@ spinner()
|
|||||||
function removeAndPurge {
|
function removeAndPurge {
|
||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ":::"
|
echo ":::"
|
||||||
for i in "${PIHOLE_DEPS[@]}"; do
|
# Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common
|
||||||
package_check $i > /dev/null
|
dependencies=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
|
||||||
if [ $? -eq 0 ]; then
|
for i in "${dependencies[@]}"; do
|
||||||
|
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
||||||
while true; do
|
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 apt-get -y remove --purge "$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
|
||||||
@@ -97,8 +65,10 @@ echo ":::"
|
|||||||
$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 remaining dependencies..."
|
||||||
package_cleanup &> /dev/null & spinner $!; printf "done!\n";
|
$SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "done!\n";
|
||||||
|
printf "::: Auto cleaning remaining dependencies..."
|
||||||
|
$SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "done!\n";
|
||||||
|
|
||||||
# Call removeNoPurge to remove PiHole specific files
|
# Call removeNoPurge to remove PiHole specific files
|
||||||
removeNoPurge
|
removeNoPurge
|
||||||
@@ -137,8 +107,7 @@ function removeNoPurge {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Removing config files and scripts..."
|
echo "::: Removing config files and scripts..."
|
||||||
package_check $i > /dev/null
|
if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -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
|
||||||
@@ -153,9 +122,8 @@ function removeNoPurge {
|
|||||||
$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
|
||||||
$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"
|
||||||
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
||||||
@@ -174,3 +142,5 @@ while true; do
|
|||||||
[Nn]* ) removeNoPurge; break;;
|
[Nn]* ) removeNoPurge; break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ else
|
|||||||
echo "::: sudo will be used."
|
echo "::: sudo will be used."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this script as root."
|
echo "::: Please install sudo or run this script as root."
|
||||||
@@ -152,7 +152,7 @@ function gravity_transport() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Silently curl url
|
# Silently curl url
|
||||||
curl -s -L $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
||||||
# Check for list updates
|
# Check for list updates
|
||||||
gravity_patternCheck "$patternBuffer"
|
gravity_patternCheck "$patternBuffer"
|
||||||
# Cleanup
|
# Cleanup
|
||||||
@@ -181,7 +181,7 @@ function gravity_spinup() {
|
|||||||
# to complete properly and reset the user agent when required
|
# to complete properly and reset the user agent when required
|
||||||
case "$domain" in
|
case "$domain" in
|
||||||
"adblock.mahakala.is")
|
"adblock.mahakala.is")
|
||||||
agent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
||||||
cmd_ext="-e http://forum.xda-developers.com/"
|
cmd_ext="-e http://forum.xda-developers.com/"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
39
pihole
39
pihole
@@ -17,7 +17,7 @@ if [[ ! $EUID -eq 0 ]];then
|
|||||||
#echo "::: Sudo will be used for this tool."
|
#echo "::: Sudo will be used for this tool."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
@@ -57,6 +57,11 @@ function updateGravityFunc {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatePiholeFunc {
|
||||||
|
$SUDO /opt/pihole/updatePihole.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
function setupLCDFunction {
|
function setupLCDFunction {
|
||||||
$SUDO /opt/pihole/setupLCD.sh
|
$SUDO /opt/pihole/setupLCD.sh
|
||||||
exit 1
|
exit 1
|
||||||
@@ -75,21 +80,22 @@ function uninstallFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function helpFunc {
|
function helpFunc {
|
||||||
echo "::: Control all PiHole specific functions!"
|
echo "::: Control all PiHole specific functions!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: pihole [options]"
|
echo "::: Usage: pihole [options]"
|
||||||
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
|
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Options:"
|
echo "::: Options:"
|
||||||
echo "::: -w, whitelist Whitelist domains"
|
echo "::: -w, whitelist Whitelist domains"
|
||||||
echo "::: -b, blacklist Blacklist domains"
|
echo "::: -b, blacklist Blacklist domains"
|
||||||
echo "::: -d, debug Start a debugging session if having trouble"
|
echo "::: -d, debug Start a debugging session if having trouble"
|
||||||
echo "::: -f, flush Flush the pihole.log file"
|
echo "::: -f, flush Flush the pihole.log file"
|
||||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
echo "::: -u, updateDashboard Update the web dashboard manually"
|
||||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
echo "::: -up, updatePihole Update the Pi-hole core files manually"
|
||||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
||||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
||||||
echo "::: -h, help Show this help dialog"
|
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
||||||
|
echo "::: -h, help Show this help dialog"
|
||||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -105,6 +111,7 @@ case "$1" in
|
|||||||
"-d" | "debug" ) debugFunc;;
|
"-d" | "debug" ) debugFunc;;
|
||||||
"-f" | "flush" ) flushFunc;;
|
"-f" | "flush" ) flushFunc;;
|
||||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
||||||
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
"-g" | "updateGravity" ) updateGravityFunc;;
|
||||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
|
|||||||
Reference in New Issue
Block a user