Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
caaee40889 | ||
|
2ce47f49b1 | ||
|
0250e03b86 | ||
|
3c4a305976 | ||
|
9ccf9d57a8 | ||
|
366fcf76f6 | ||
|
72e8ec7d93 | ||
|
13a479a9f6 | ||
|
1194e48bd8 | ||
|
1e0666d1ef | ||
|
1c53ad6876 | ||
|
dc2a537f6b | ||
|
a5d3022e9f | ||
|
4541da1f17 | ||
|
a16cd9aef7 | ||
|
6cf446032f | ||
|
3fda2d9ac3 | ||
|
c03268707a | ||
|
7829e907c9 | ||
|
b5529e5138 | ||
|
d601afcebc | ||
|
892a90bf51 | ||
|
d52a8f08ed | ||
|
b7e27bf6b4 | ||
|
9ee96d6176 | ||
|
c0e1772e21 | ||
|
62dc160c65 | ||
|
f03303e5aa | ||
|
7bc2844b9d | ||
|
ba283755be | ||
|
2209beff8a | ||
|
00cc480bc1 | ||
|
d7de5b2afa | ||
|
221b72439b | ||
|
08e6f60941 | ||
|
10066209e7 | ||
|
08e95ed606 | ||
|
a5ad48aa18 | ||
|
81fdfcba22 | ||
|
24de6d6fc9 | ||
|
aec6fcd00b | ||
|
619082dbed | ||
|
09cdf5081c | ||
|
d7abbbfac4 | ||
|
c714196647 | ||
|
b702c1d9a8 | ||
|
56ac04c48e | ||
|
b58519b974 | ||
|
ad574f5e90 | ||
|
4941a657bf | ||
|
3d4bff9414 | ||
|
2d03616c10 | ||
|
fcb9ba08a8 | ||
|
77f4126f9b | ||
|
4c890ab202 | ||
|
d10e9b1b6e | ||
|
a6bee76581 | ||
|
2f4f5a6ad2 | ||
|
3853997295 | ||
|
76899c9ac5 | ||
|
99a5b3a98a | ||
|
219aff9a93 | ||
|
b6e1b3bff0 | ||
|
1ce888e828 | ||
|
1c10a801dc | ||
|
48fa83c9ac | ||
|
31ea3a2757 | ||
|
05e0003555 | ||
|
be79281418 | ||
|
01f53f6d6c | ||
|
107e0404de | ||
|
ab99e80333 | ||
|
3154a378a6 | ||
|
8e04f1c03e | ||
|
c0aadeab3d | ||
|
6c87698f1a | ||
|
db2e9f8bf3 | ||
|
9a4c5cef86 | ||
|
bdfc86f850 | ||
|
70dadfba28 | ||
|
01e1e34874 | ||
|
28a3cbfa87 | ||
|
0b480c2d3f | ||
|
391dea445a | ||
|
e074c72130 | ||
|
96f3f863e5 | ||
|
3877f6fd94 | ||
|
cbbc6df05a | ||
|
32ff7fb321 | ||
|
5537e57eec | ||
|
9c94af04cc | ||
|
3f0b15902d | ||
|
4d3835dde2 | ||
|
8514f42d0d | ||
|
834bf30a10 | ||
|
22ea384ac8 |
119
README.md
119
README.md
@@ -1,12 +1,9 @@
|
||||
# Automated Install
|
||||
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
||||
|
||||
|
||||
[](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
1. Install Raspbian
|
||||
|
||||
2. Run the command below
|
||||
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!)
|
||||
|
||||
### ```curl -L https://install.pi-hole.net | bash```
|
||||
|
||||
@@ -16,23 +13,76 @@ wget -O basic-install.sh https://install.pi-hole.net
|
||||
chmod +x 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/).
|
||||
|
||||
## Pi-hole Is Free, But Powered By Your Donations
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
|
||||
## How To Install Pi-hole
|
||||
|
||||
## 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/)
|
||||
[](https://www.youtube.com/watch?v=TzFLJqUeirA)
|
||||
|
||||
## How Does It Work?
|
||||
**Watch the 60-second video below to get a quick overview**
|
||||
|
||||
[](https://vimeo.com/135965232)
|
||||
[](https://youtu.be/L2iVKs0v0Tk)
|
||||
|
||||
## 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 stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
||||
@@ -59,52 +109,5 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
||||
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
||||
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
||||
|
||||
## Partnering With Optimal.com
|
||||
|
||||
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
|
||||
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 21/02/2016 #########################
|
||||
## Pi-hole ad-list default sources. Updated 22/05/2016 #########################
|
||||
# #
|
||||
# To make changes to this file: #
|
||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||
# 2. run `nano /etc/pihole/adlists.list` #
|
||||
# 3. Uncomment or comment any of the below lists #
|
||||
# #
|
||||
@@ -22,7 +22,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||
|
||||
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||
http://hosts-file.net/ad_servers.txt
|
||||
https://hosts-file.net/ad_servers.txt
|
||||
|
||||
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
||||
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
||||
@@ -32,7 +32,7 @@ http://hosts-file.net/ad_servers.txt
|
||||
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||
|
||||
# Windows 10 telemetry list
|
||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt
|
||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
||||
|
||||
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||
#http://securemecca.com/Downloads/hosts.txt
|
||||
@@ -48,3 +48,6 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
||||
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||
#http://spam404bl.com/spam404scamlist.txt
|
||||
#http://malwaredomains.lehigh.edu/files/domains.txt
|
||||
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
|
||||
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
||||
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
||||
|
@@ -10,17 +10,39 @@
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (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 [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
function helpFunc()
|
||||
{
|
||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
echo "::: -l, --list Display your blacklisted domains"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
exit 1
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
#globals
|
||||
@@ -31,17 +53,24 @@ blacklist=$piholeDir/blacklist.txt
|
||||
reload=true
|
||||
addmode=true
|
||||
force=false
|
||||
versbose=true
|
||||
verbose=true
|
||||
|
||||
domList=()
|
||||
domToRemoveList=()
|
||||
|
||||
piholeIPfile=/etc/pihole/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
if [[ -f $piholeIPfile ]];then
|
||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||
piholeIP=$(cat $piholeIPfile)
|
||||
#rm $piholeIPfile
|
||||
else
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
fi
|
||||
|
||||
modifyHost=false
|
||||
|
||||
@@ -57,13 +86,12 @@ if [[ -f $piholeIPv6file ]];then
|
||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||
fi
|
||||
|
||||
|
||||
function HandleOther(){
|
||||
#check validity of domain
|
||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
if [ -z "$validDomain" ]; then
|
||||
echo "::: $1 is not a valid argument or domain name"
|
||||
else
|
||||
else
|
||||
domList=("${domList[@]}" $validDomain)
|
||||
fi
|
||||
}
|
||||
@@ -88,14 +116,14 @@ function AddDomain(){
|
||||
grep -Ex -q "$1" $blacklist || bool=true
|
||||
if $bool; then
|
||||
#domain not found in the blacklist file, add it!
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo -n "::: Adding $1 to blacklist file..."
|
||||
fi
|
||||
echo "$1" >> $blacklist
|
||||
modifyHost=true
|
||||
echo " done!"
|
||||
else
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo "::: $1 already exists in $blacklist! No need to add"
|
||||
fi
|
||||
fi
|
||||
@@ -107,12 +135,12 @@ function RemoveDomain(){
|
||||
grep -Ex -q "$1" $blacklist || bool=true
|
||||
if $bool; then
|
||||
#Domain is not in the blacklist file, no need to Remove
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo "::: $1 is NOT blacklisted! No need to remove"
|
||||
fi
|
||||
else
|
||||
#Domain is in the blacklist file, add to a temporary array
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo "::: Un-blacklisting $dom..."
|
||||
fi
|
||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||
@@ -127,12 +155,12 @@ function ModifyHostFile(){
|
||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||
echo ":::"
|
||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||
else
|
||||
else
|
||||
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo ":::"
|
||||
@@ -141,7 +169,7 @@ function ModifyHostFile(){
|
||||
#we need to remove the domains from the blacklist file and the host file
|
||||
echo "::: $dom"
|
||||
echo -n "::: removing from HOSTS file..."
|
||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||
echo " done!"
|
||||
echo -n "::: removing from blackist.txt..."
|
||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
||||
@@ -159,14 +187,25 @@ function Reload() {
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
sudo kill -HUP "$dnsmasqPid"
|
||||
$SUDO killall -s HUP dnsmasq
|
||||
else
|
||||
# service not running, start it up
|
||||
sudo service dnsmasq start
|
||||
$SUDO service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
function DisplayBlist() {
|
||||
verbose=false
|
||||
echo -e " Displaying Gravity Affected Domains \n"
|
||||
count=1
|
||||
while IFS= read -r AD
|
||||
do
|
||||
echo "${count}: $AD"
|
||||
count=$((count+1))
|
||||
done < "$blacklist"
|
||||
}
|
||||
|
||||
###################################################
|
||||
|
||||
for var in "$@"
|
||||
@@ -175,7 +214,9 @@ do
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-d" | "--delmode" ) addmode=false;;
|
||||
"-f" | "--force" ) force=true;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
"-q" | "--quiet" ) verbose=false;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
"-l" | "--list" ) DisplayBlist;;
|
||||
* ) HandleOther "$var";;
|
||||
esac
|
||||
done
|
||||
@@ -185,8 +226,8 @@ PopBlacklistFile
|
||||
if $modifyHost || $force; then
|
||||
ModifyHostFile
|
||||
else
|
||||
if $versbose; then
|
||||
echo "::: No changes need to be made"
|
||||
if $verbose; then
|
||||
echo "::: No changes need to be made"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
@@ -84,7 +84,11 @@ function normalChrono(){
|
||||
do
|
||||
clear
|
||||
# Displays a colorful Pi-hole logo
|
||||
toilet -f small -F gay Pi-hole
|
||||
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||
echo ""
|
||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||
echo ""
|
||||
uptime | cut -d' ' -f11-
|
||||
@@ -120,7 +124,7 @@ function normalChrono(){
|
||||
function displayHelp(){
|
||||
echo "::: Displays stats about your piHole!"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -c [optional:-j]"
|
||||
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
|
@@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log"
|
||||
DNSMASQFILE="/etc/dnsmasq.conf"
|
||||
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
||||
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
||||
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
|
||||
GRAVITYFILE="/etc/pihole/gravity.list"
|
||||
HOSTSFILE="/etc/hosts"
|
||||
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
||||
@@ -53,6 +54,19 @@ else
|
||||
fi
|
||||
|
||||
### Private functions exist here ###
|
||||
function versionCheck {
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "########## Versions Section ###########" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
|
||||
TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
echo "Pi-hole Version: $TMP" >> $DEBUG_LOG
|
||||
|
||||
TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0)
|
||||
echo "WebUI Version: $TMP" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
}
|
||||
|
||||
function compareWhitelist {
|
||||
if [ ! -f "$WHITELISTMATCHES" ]; then
|
||||
$SUDO touch $WHITELISTMATCHES
|
||||
@@ -126,12 +140,44 @@ function checkProcesses {
|
||||
for i in "${PROCESSES[@]}"
|
||||
do
|
||||
echo "" >> $DEBUG_LOG
|
||||
echo -n $i >> "$DEBUG_LOG"
|
||||
echo -n "$i" >> "$DEBUG_LOG"
|
||||
echo " processes status:" >> $DEBUG_LOG
|
||||
$SUDO systemctl -l status $i >> "$DEBUG_LOG"
|
||||
$SUDO systemctl -l status "$i" >> "$DEBUG_LOG"
|
||||
done
|
||||
}
|
||||
|
||||
function debugLighttpd {
|
||||
echo "::: Writing lighttpd to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$LIGHTTPDFILE" ]
|
||||
then
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
echo "$line" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$LIGHTTPDFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo lighttpd.conf file found\n"
|
||||
fi
|
||||
|
||||
if [ -e "$LIGHTTPDERRFILE" ]
|
||||
then
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "######### lighttpd error.log ##########" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG
|
||||
else
|
||||
echo "No lighttpd error.log file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo lighttpd error.log file found\n"
|
||||
fi
|
||||
echo >> $DEBUG_LOG
|
||||
}
|
||||
|
||||
### END FUNCTIONS ###
|
||||
|
||||
### Check Pi internet connections ###
|
||||
@@ -148,10 +194,12 @@ echo "Gateway check:" >> $DEBUG_LOG
|
||||
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
||||
echo >> $DEBUG_LOG
|
||||
|
||||
versionCheck
|
||||
compareWhitelist
|
||||
compareBlacklist
|
||||
testNslookup
|
||||
checkProcesses
|
||||
debugLighttpd
|
||||
|
||||
echo "::: Writing dnsmasq.conf to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
@@ -178,7 +226,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$PIHOLECONFFILE" ]
|
||||
then
|
||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
@@ -191,25 +238,6 @@ else
|
||||
printf ":::\tNo 01-pihole.conf file found\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing lighttpd.conf to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
if [ -e "$LIGHTTPDFILE" ]
|
||||
then
|
||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
||||
while read -r line; do
|
||||
if [ ! -z "$line" ]; then
|
||||
[[ "$line" =~ ^#.*$ ]] && continue
|
||||
echo "$line" >> $DEBUG_LOG
|
||||
fi
|
||||
done < "$LIGHTTPDFILE"
|
||||
echo >> $DEBUG_LOG
|
||||
else
|
||||
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
|
||||
printf ":::\tNo lighttpd.conf file found\n"
|
||||
fi
|
||||
|
||||
echo "::: Writing size of gravity.list to debug log..."
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############ gravity.list #############" >> $DEBUG_LOG
|
||||
@@ -283,7 +311,7 @@ fi
|
||||
|
||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||
function dumpPiHoleLog {
|
||||
trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
||||
echo "#######################################" >> $DEBUG_LOG
|
||||
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
||||
@@ -302,7 +330,8 @@ function dumpPiHoleLog {
|
||||
|
||||
# Anything to be done after capturing of pihole.log terminates
|
||||
function finalWork {
|
||||
echo "::: Finshed debugging!"
|
||||
echo "::: Finshed debugging!"
|
||||
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
||||
}
|
||||
trap finalWork EXIT
|
||||
|
||||
|
@@ -10,17 +10,39 @@
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (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 [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
function helpFunc()
|
||||
{
|
||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
echo "::: -l, --list Display your whitelisted domains"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
exit 1
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
#globals
|
||||
@@ -31,17 +53,24 @@ whitelist=$piholeDir/whitelist.txt
|
||||
reload=true
|
||||
addmode=true
|
||||
force=false
|
||||
versbose=true
|
||||
verbose=true
|
||||
|
||||
domList=()
|
||||
domToRemoveList=()
|
||||
|
||||
piholeIPfile=/etc/pihole/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
if [[ -f $piholeIPfile ]];then
|
||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||
piholeIP=$(cat $piholeIPfile)
|
||||
#rm $piholeIPfile
|
||||
else
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
fi
|
||||
|
||||
modifyHost=false
|
||||
|
||||
@@ -56,7 +85,6 @@ if [[ -f $piholeIPv6file ]];then
|
||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||
fi
|
||||
|
||||
|
||||
function HandleOther(){
|
||||
#check validity of domain
|
||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||
@@ -89,16 +117,16 @@ function AddDomain(){
|
||||
grep -Ex -q "$1" $whitelist || bool=true
|
||||
if $bool; then
|
||||
#domain not found in the whitelist file, add it!
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo -n "::: Adding $1 to $whitelist..."
|
||||
fi
|
||||
echo "$1" >> $whitelist
|
||||
modifyHost=true
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo " done!"
|
||||
fi
|
||||
else
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo "::: $1 already exists in $whitelist, no need to add!"
|
||||
fi
|
||||
fi
|
||||
@@ -110,12 +138,12 @@ function RemoveDomain(){
|
||||
grep -Ex -q "$1" $whitelist || bool=true
|
||||
if $bool; then
|
||||
#Domain is not in the whitelist file, no need to Remove
|
||||
if $versbose; then
|
||||
if $verbose; then
|
||||
echo "::: $1 is NOT whitelisted! No need to remove"
|
||||
fi
|
||||
else
|
||||
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file
|
||||
#if $versbose; then
|
||||
#if $verbose; then
|
||||
#echo "::: Un-whitelisting $dom..."
|
||||
#fi
|
||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
||||
@@ -172,14 +200,25 @@ function Reload() {
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
sudo kill -HUP "$dnsmasqPid"
|
||||
$SUDO killall -s HUP dnsmasq
|
||||
else
|
||||
# service not running, start it up
|
||||
sudo service dnsmasq start
|
||||
$SUDO service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
function DisplayWlist() {
|
||||
verbose=false
|
||||
echo -e " Displaying Gravity Resistant Domains \n"
|
||||
count=1
|
||||
while IFS= read -r RD
|
||||
do
|
||||
echo "${count}: $RD"
|
||||
count=$((count+1))
|
||||
done < "$whitelist"
|
||||
}
|
||||
|
||||
###################################################
|
||||
|
||||
for var in "$@"
|
||||
@@ -188,7 +227,9 @@ do
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-d" | "--delmode" ) addmode=false;;
|
||||
"-f" | "--force" ) force=true;;
|
||||
"-q" | "--quiet" ) versbose=false;;
|
||||
"-q" | "--quiet" ) verbose=false;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
"-l" | "--list" ) DisplayWlist;;
|
||||
* ) HandleOther "$var";;
|
||||
esac
|
||||
done
|
||||
@@ -198,11 +239,11 @@ PopWhitelistFile
|
||||
if $modifyHost || $force; then
|
||||
ModifyHostFile
|
||||
else
|
||||
if $versbose; then
|
||||
echo ":::"
|
||||
echo "::: No changes need to be made"
|
||||
exit 1
|
||||
if $verbose; then
|
||||
echo ":::"
|
||||
echo "::: No changes need to be made"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $reload; then
|
||||
|
@@ -46,13 +46,16 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
||||
# 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!" )
|
||||
setenv.add-response-header = (
|
||||
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||
"X-Frame-Options" => "DENY"
|
||||
)
|
||||
}
|
||||
|
||||
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||
$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")
|
||||
# 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")
|
||||
}
|
||||
|
@@ -11,16 +11,16 @@
|
||||
|
||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||
# Download any updates from the adlists
|
||||
59 1 * * 7 root /usr/local/bin/gravity.sh
|
||||
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
||||
|
||||
# Pi-hole: Update the Web interface shortly after gravity runs
|
||||
# This should also update the version number if it is changed in the dashboard repo
|
||||
30 2 * * 7 root /usr/local/bin/updateDashboard.sh
|
||||
30 2 * * 7 root /usr/local/bin/pihole updateDashboard
|
||||
|
||||
# Pi-hole: Parse the log file before it is flushed and save the stats to a database
|
||||
# This will be used for a historical view of your Pi-hole's performance
|
||||
#50 23 * * * root /usr/local/bin/dailyLog.sh
|
||||
#50 23 * * * root /usr/local/bin/dailyLog.sh # note: this is outdated
|
||||
|
||||
# Pi-hole: Flush the log daily at 11:58 so it doesn't get out of control
|
||||
# Stats will be viewable in the Web interface thanks to the cron job above
|
||||
58 23 * * * root /usr/local/bin/piholeLogFlush.sh
|
||||
58 23 * * * root /usr/local/bin/pihole flush
|
||||
|
12
advanced/pihole.sudo
Normal file
12
advanced/pihole.sudo
Normal file
@@ -0,0 +1,12 @@
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Allows the WebUI to use Pi-hole commands
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
www-data ALL=NOPASSWD: /usr/local/bin/pihole
|
@@ -43,7 +43,7 @@ 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)
|
||||
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1)
|
||||
dhcpcdFile=/etc/dhcpcd.conf
|
||||
|
||||
######## FIRST CHECK ########
|
||||
@@ -58,7 +58,7 @@ else
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -110,7 +110,8 @@ welcomeDialogs() {
|
||||
|
||||
# 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.
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +175,7 @@ cleanupIPv6() {
|
||||
|
||||
use4andor6() {
|
||||
# Let use select IPv4 and/or IPv6
|
||||
cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2)
|
||||
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" $r $c 2)
|
||||
options=(IPv4 "Block ads over IPv4" on
|
||||
IPv6 "Block ads over IPv6" off)
|
||||
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
||||
@@ -232,8 +233,10 @@ getStaticIPv4Settings() {
|
||||
Gateway: $IPv4gw" $r $c) then
|
||||
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
|
||||
whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
|
||||
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
|
||||
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
|
||||
#piholeIP is saved to a permanent file so gravity.sh can use it when updating
|
||||
echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
||||
# Nothing else to do since the variables are already set above
|
||||
else
|
||||
# Otherwise, we need to ask the user to input their desired settings.
|
||||
@@ -254,8 +257,8 @@ getStaticIPv4Settings() {
|
||||
IP address: $IPv4addr
|
||||
Gateway: $IPv4gw" $r $c)then
|
||||
# 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
|
||||
echo "${IPv4addr%/*}" > /tmp/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
|
||||
echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
||||
echo "$piholeInterface" > /tmp/piholeINT
|
||||
# After that's done, the loop ends and we move on
|
||||
ipSettingsCorrect=True
|
||||
@@ -545,7 +548,7 @@ checkForDependencies() {
|
||||
echo ":::"
|
||||
echo "::: Checking dependencies:"
|
||||
|
||||
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget )
|
||||
dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo)
|
||||
for i in "${dependencies[@]}"; do
|
||||
echo -n "::: Checking for $i..."
|
||||
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||
@@ -635,6 +638,12 @@ installPiholeWeb() {
|
||||
$SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/.
|
||||
$SUDO echo " done!"
|
||||
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() {
|
||||
@@ -695,12 +704,13 @@ displayFinalMessage() {
|
||||
# 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:
|
||||
|
||||
$IPv4addr
|
||||
$piholeIPv6
|
||||
IPv4: ${IPv4addr%/*}
|
||||
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." $r $c
|
||||
The install log is in /etc/pihole.
|
||||
View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" $r $c
|
||||
}
|
||||
|
||||
######## SCRIPT ############
|
||||
@@ -737,10 +747,10 @@ echo " done."
|
||||
|
||||
echo ":::"
|
||||
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
||||
echo "::: $IPv4addr"
|
||||
echo "::: ${IPv4addr%/*}"
|
||||
echo "::: $piholeIPv6"
|
||||
echo ":::"
|
||||
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 "::: View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin"
|
||||
|
@@ -44,7 +44,7 @@ function removeAndPurge {
|
||||
# Purge dependencies
|
||||
echo ":::"
|
||||
# Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common
|
||||
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common git curl unzip wget )
|
||||
dependencies=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
|
||||
for i in "${dependencies[@]}"; do
|
||||
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
||||
while true; do
|
||||
@@ -122,8 +122,9 @@ function removeNoPurge {
|
||||
$SUDO rm -rf /etc/.pihole/ &> /dev/null
|
||||
$SUDO rm -rf /opt/pihole/ &> /dev/null
|
||||
$SUDO rm /usr/local/bin/pihole &> /dev/null
|
||||
$SUDO rm /etc/bash_completion.d/pihole
|
||||
|
||||
$SUDO rm /etc/bash_completion.d/pihole &> /dev/null
|
||||
$SUDO rm /etc/sudoers.d/pihole &> /dev/null
|
||||
|
||||
echo ":::"
|
||||
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
||||
|
37
gravity.sh
37
gravity.sh
@@ -12,6 +12,7 @@
|
||||
|
||||
# Run this script as root or under sudo
|
||||
echo ":::"
|
||||
|
||||
if [[ $EUID -eq 0 ]];then
|
||||
echo "::: You are root."
|
||||
else
|
||||
@@ -26,7 +27,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
piholeIPfile=/tmp/piholeIP
|
||||
piholeIPfile=/etc/pihole/piholeIP
|
||||
piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
adListFile=/etc/pihole/adlists.list
|
||||
@@ -37,7 +38,7 @@ blacklistScript=/opt/pihole/blacklist.sh
|
||||
if [[ -f $piholeIPfile ]];then
|
||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||
piholeIP=$(cat $piholeIPfile)
|
||||
rm $piholeIPfile
|
||||
#rm $piholeIPfile
|
||||
else
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
@@ -71,20 +72,6 @@ if [[ -r $piholeDir/pihole.conf ]];then
|
||||
. $piholeDir/pihole.conf
|
||||
fi
|
||||
|
||||
spinner() {
|
||||
local pid=$1
|
||||
local delay=0.50
|
||||
local spinstr='/-|'
|
||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=$temp${spinstr%"$temp"}
|
||||
sleep $delay
|
||||
printf "\b\b\b\b\b\b"
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
}
|
||||
|
||||
###########################
|
||||
# collapse - begin formation of pihole
|
||||
function gravity_collapse() {
|
||||
@@ -214,7 +201,7 @@ function gravity_Schwarzchild() {
|
||||
echo "::: "
|
||||
# Find all active domains and compile them into one file and remove CRs
|
||||
echo -n "::: Aggregating list of domains..."
|
||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
||||
truncate -s 0 $piholeDir/$matterandlight
|
||||
for i in "${activeDomains[@]}"
|
||||
do
|
||||
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
|
||||
@@ -225,7 +212,7 @@ function gravity_Schwarzchild() {
|
||||
function gravity_Blacklist(){
|
||||
# Append blacklist entries if they exist
|
||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
||||
$blacklistScript -f -nr -q > /dev/null
|
||||
|
||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||
@@ -247,7 +234,7 @@ function gravity_Whitelist() {
|
||||
echo " done!"
|
||||
|
||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $!
|
||||
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null
|
||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
||||
@@ -256,7 +243,7 @@ function gravity_Whitelist() {
|
||||
function gravity_unique() {
|
||||
# Sort and remove duplicates
|
||||
echo -n "::: Removing duplicate domains...."
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $!
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
|
||||
echo " done!"
|
||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
||||
echo "::: $numberOf unique domains trapped in the event horizon."
|
||||
@@ -302,7 +289,7 @@ function gravity_advanced() {
|
||||
# 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
|
||||
echo -n "::: Formatting list of domains to remove comments...."
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $!
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
|
||||
echo " done!"
|
||||
|
||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
||||
@@ -326,17 +313,17 @@ function gravity_reload() {
|
||||
#First escape forward slashes in the path:
|
||||
adList=${adList//\//\\\/}
|
||||
#Now replace the line in dnsmasq file
|
||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adlist/" /etc/dnsmasq.d/01-pihole.conf
|
||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \;
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
$SUDO kill -HUP "$dnsmasqPid" & spinner $!
|
||||
$SUDO killall -s HUP dnsmasq
|
||||
else
|
||||
# service not running, start it up
|
||||
$SUDO service dnsmasq start & spinner $!
|
||||
$SUDO service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
45
pihole
45
pihole
@@ -11,10 +11,10 @@
|
||||
# (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."
|
||||
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
|
||||
@@ -63,7 +63,8 @@ function setupLCDFunction {
|
||||
}
|
||||
|
||||
function chronometerFunc {
|
||||
$SUDO /opt/pihole/chronometer.sh
|
||||
shift
|
||||
$SUDO /opt/pihole/chronometer.sh "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -74,23 +75,23 @@ function uninstallFunc {
|
||||
}
|
||||
|
||||
function helpFunc {
|
||||
echo "::: Control all PiHole specific functions!"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole.sh [options]"
|
||||
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -w, whitelist Whitelist domains"
|
||||
echo "::: -b, blacklist Blacklist domains"
|
||||
echo "::: -d, debug Start a debugging session if having trouble"
|
||||
echo "::: -f, flush Flush the pihole.log file"
|
||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
||||
echo "::: -h, help Show this help dialog"
|
||||
echo "::: 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 "::: -u, updateDashboard Update the web dashboard manually"
|
||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
||||
echo "::: -h, help Show this help dialog"
|
||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
@@ -106,7 +107,7 @@ case "$1" in
|
||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||
"-c" | "chronometer" ) chronometerFunc;;
|
||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||
"-h" | "help" ) helpFunc;;
|
||||
"uninstall" ) uninstallFunc;;
|
||||
* ) helpFunc;;
|
||||
|
Reference in New Issue
Block a user