epel-release installs the EPEL package repository (Extra Packages for Enterprise Linux)
Dependencies from this repository should available by default on Fedora
Removed a few checkboxes. I really don't want to deter people from
submitting issue because of a wall of text, but some of this
information we really can use to be more helpful.
- Test if /etc/hostname exists before attempting to cat the file.
- Add alternative hostname discovery via hostname command
- Add an error message to stdout if unable to determine host fqdn
* adding links to optimal.com
Also added image of Pi-hole's stats from Optimal.com and a bitcoin donation address per some user requests.
* simplified and new additions
I tried to simplify the readme page a bit. I also added some new links to some helper videos and added some screenshots of the whitelist editor.
* updated dashboard pic
* Update README.md
* simplified donation section
* forgot to remove the old donation stuff
* Hosts-file.net moved to https
* removed pihole berry from images
also added adafruit livestream video
* Update README.md
update "How does it work" video
The hosts-blocklist is a semi-automatically updated list, based on various well known public sources, for more details read: https://github.com/notracking/hosts-blocklists/
Please be aware that one file is for domain blocking and the other file for hostname based blocking, these lists are complimentary and should therefore be used simultaneously.
* Change dummy domain
Allows users to access Pi-hole console with my.pi-hole.net instead of the IP address
* Cleaned up formatting
* Put device hostname at the top of the list
Changed my.pi-hole.net to pi.hole and placed it under the device hostname. This way, ping will return the device hostname but you still can access the web interface with pi.hole/admin
Removed symlink of scripts to u/l/b
Added copy for setupLCD to /opt/pihole/
New spinner added to gravity.sh to reflect new spinner in basic-install.sh and uninstall.sh
Syntax of uninstall script now matches basic-install.sh.
More error handling of missing default files.
Force user prompt for removing packages when uninstalling.
Added links to where code was borrowed from
added reboot at the end
also added a few things commented out that might be useful for some
people to learn.
addresses #322. Will now check free space on the first file system output by 'df- lkP`, as opposed to `/` to make pi-hole more compatible with other distros.
Do not stop dnsmasq when installing. Instead run `service dnsmasq restart` once installation is complete.
This may have been the cause of issues outlined in #218
Give the user the ability to choose between Google and DynDNS upstream
servers. Then insert the chosen DNS servers in to
/etc/dnsmasq.d/01-pihole.conf. Todo: extend choices to include manually
entered DNS servers.
Prep for using sed to insert user selected DNSs into 01-pihole.conf.
Selections will come from dialog during install script containing the
following choices: Google, DynDNS, and eventually 2 custom DNS servers.
Check if /etc/dnsmasq.conf is from pihole. If so, replace with an
original and install new in .d directory. Add and unmolested version of
dnsmasq.conf to the ./advanced directory.
This puts sudo in a variable if run as a regular user. If already
running as root, the script proceeds as normal. Not a perfect fix, but
should help for install on other systems.
- removed most of the video images to reduce clutter
- converged the "coverage" and "video" sections into a bulleted list of links
- added a new project link (pi-hole on/off button)
- moved projects up in the page so it's easier to find and see what people are doing with Pi-hole
- removed custom conf section since it will be suited better in the wiki or FAQs
- added a help section
Failed to be populated if /tmp/piholeIP does not exist. This may happen under
the following conditions:
- was not generated during install
- gravity.sh being run again after the original install (the file is deleted
during the installation process)
- Rob's post on medium.com
- TekThing video
Also posting about plans to partner up with Rob for his new service that can help reduce the flame war surrounding ad blocking
I wanted the whitelist feature to keep the user on the same page
without having to reload it. I'm sure someone better versed in PHP
could eliminate the need for this hack. Nonetheless, it works.
www-data runs the script if executed from the Web interface. www-data
also needs access to write to /etc/pihole/gravity.list to actually
remove the domain. So a few more things need to happen before this
will fully work.
The changes in this script won't change what is displayed if run from
the terminal, but will help when it needs to be run from the Web
interface, so I am just committing this now.
The only other thing I would like to see would be a progress spinner,
but my Web skills still need some work...
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
**In raising this issue, I confirm the following (please check boxes, eg [X]):**
- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
- [ ] The issue I am reporting can be *replicated*
- [ ] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)).
**How familiar are you with the codebase?:**
- [ ] 1 (very unfamiliar)
- [ ] 2
- [ ] 3
- [ ] 4
- [ ] 5
- [ ] 6
- [ ] 7
- [ ] 8
- [ ] 9
- [ ] 10 (very familiar)
---
**[FEATURE REQUEST | QUESTION | OTHER]:**
_{replace this section with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_
**[BUG | ISSUE] Expected Behaviour:**
**[BUG | ISSUE] Actual Behaviour:**
**[BUG | ISSUE] Steps to reproduce:**
-
-
-
-
**(Optional) Debug Log generated by `pihole -d`:**
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
# Contributors Guide
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature.
- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that.
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many people, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project.
## Procedure
**Before filing an issue:**
- Attempt to replicate and **document** the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
**Before submitting a pull request:**
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Technical Requirements
- Submit Pull Requests to the **development branch only**.
- Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
- Commit Unix line endings.
- (Optional fun) keep to the theme of Star Trek/black holes/gravity.
Designed For Raspberry Pi A+, B, B+, 2, 3B, and Zero (with an Ethernet/Wi-Fi adapter)
Works on most Debian and CentOS/RHEL based distributions!
### ```curl -L install.pi-hole.net | bash```
1. Install Raspbian
2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!)
Once installed, **configure any device to use the Raspberry Pi as its DNS server and the ads will be blocked**. You can also configure your router's DHCP options to assign the Pi as clients DNS server so they do not need to do it manually.
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/).
The Pi-hole is a DNS/Web server that will **block ads for any device on your network**.
Pi-hole is mentioned at 100 minutes and 26 seconds (the link brings you right there)
[](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
## How It Works
### Tech Blogs
**Watch the 60-second video below to get a quick overview**
Featured on [MakeUseOf](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) and [Lifehacker](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)!
- [](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Technical Details
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).
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/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0).
### Gravity
## Whitelist and blacklist
You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically.
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`
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`
## Custom Config File
If you want to use your own variables for the gravity script (i.e. storing the files in a different location) and don't want to have to change them every time there is an update to the script, create a file called `/etc/pihole/pihole.conf`. In it, you should add your own variables in a similar fashion as shown below:
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"
}
```
See [this PR](https://github.com/jacobsalmela/pi-hole/pull/20) for more details.
The same output can be achieved on the CLI by running `chronometer.sh -j`
### How It Works
A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)!
## 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)
- [Docker Pi-hole container (x86 and ARM)](https://hub.docker.com/r/diginc/pi-hole/)
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/)
- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)!
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
## Other Operating Systems
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated.
### Examples Of The Pi-hole On Other Operating Systems
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
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.
# 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.
# Pi-hole: A black hole for Internet advertisements
# (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net
# Blacklists domains
#
# Pi-hole is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
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"
exit1
}
if[[$#=0]];then
helpFunc
fi
#globals
basename=pihole
piholeDir=/etc/${basename}
adList=${piholeDir}/gravity.list
blacklist=${piholeDir}/blacklist.txt
reload=true
addmode=true
force=false
verbose=true
domList=()
domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6
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
# After setting defaults, check if there's local overrides
if[[ -r ${piholeDir}/pihole.conf ]];then
echo"::: Local calibration requested..."
. ${piholeDir}/pihole.conf
fi
if[[ -f ${piholeIPv6file}]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
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
domList=("${domList[@]}"${validDomain})
fi
}
PopBlacklistFile(){
#check blacklist file exists, and if not, create it
if[[ ! -f ${blacklist}]];then
touch ${blacklist}
fi
for dom in "${domList[@]}";do
if"$addmode";then
AddDomain "$dom"
else
RemoveDomain "$dom"
fi
done
}
AddDomain(){
#| sed 's/\./\\./g'
bool=false
grep -Ex -q "$1"${blacklist}||bool=true
if${bool};then
#domain not found in the blacklist file, add it!
if${verbose};then
echo -n "::: Adding $1 to blacklist file..."
fi
echo"$1" >> ${blacklist}
modifyHost=true
echo" done!"
else
if${verbose};then
echo"::: $1 already exists in $blacklist! No need to add"
fi
fi
}
RemoveDomain(){
bool=false
grep -Ex -q "$1"${blacklist}||bool=true
if${bool};then
#Domain is not in the blacklist file, no need to Remove
if${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${verbose};then
echo"::: Un-blacklisting $dom..."
fi
domToRemoveList=("${domToRemoveList[@]}"$1)
modifyHost=true
fi
}
ModifyHostFile(){
if${addmode};then
#add domains to the hosts file
if[[ -r ${blacklist}]];then
numberOf=$(cat ${blacklist}| sed '/^\s*$/d'| wc -l)
plural=;[["$numberOf" !="1"]]&&plural=s
echo":::"
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
echo"No adlists.list file found... using adlists.default!" >> ${DEBUG_LOG}
printf":::\tNo adlists.list file found... using adlists.default!\n"
fi
# Continuously append the pihole.log file to the pihole_debug.log file
function dumpPiHoleLog {
trap'{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
# Pi-hole: A black hole for Internet advertisements
# (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net
# Whitelists domains
#
# Pi-hole is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
if[$#=0];then
echo"Immediately whitelists one or more domains."
echo"Usage: whitelist.sh domain1 [domain2 ...]"
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"
exit1
}
if[[$#=0]];then
helpFunc
fi
combopattern=""
#globals
basename=pihole
piholeDir=/etc/${basename}
adList=${piholeDir}/gravity.list
whitelist=${piholeDir}/whitelist.txt
reload=true
addmode=true
force=false
verbose=true
domList=()
domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6
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
# After setting defaults, check if there's local overrides
if[[ -r ${piholeDir}/pihole.conf ]];then
echo"::: Local calibration requested..."
. ${piholeDir}/pihole.conf
fi
if[[ -f ${piholeIPv6file}]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
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
domList=("${domList[@]}"${validDomain})
fi
}
PopWhitelistFile(){
#check whitelist file exists, and if not, create it
if[[ ! -f ${whitelist}]];then
touch ${whitelist}
fi
for dom in "${domList[@]}"
do
if${addmode};then
AddDomain "$dom"
else
RemoveDomain "$dom"
fi
done
}
AddDomain(){
#| sed 's/\./\\./g'
bool=false
grep -Ex -q "$1"${whitelist}||bool=true
if${bool};then
#domain not found in the whitelist file, add it!
if${verbose};then
echo -n "::: Adding $1 to $whitelist..."
fi
echo"$1" >> ${whitelist}
modifyHost=true
if${verbose};then
echo" done!"
fi
else
if${verbose};then
echo"::: $1 already exists in $whitelist, no need to add!"
fi
fi
}
RemoveDomain(){
bool=false
grep -Ex -q "$1"${whitelist}||bool=true
if${bool};then
#Domain is not in the whitelist file, no need to Remove
if${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 $verbose; then
#echo "::: Un-whitelisting $dom..."
#fi
domToRemoveList=("${domToRemoveList[@]}"$1)
modifyHost=true
fi
}
ModifyHostFile(){
if${addmode};then
#remove domains in from hosts file
if[[ -r ${whitelist}]];then
# Remove whitelist entries
numberOf=$(cat ${whitelist}| sed '/^\s*$/d'| wc -l)
plural=;[["$numberOf" !="1"]]&&plural=s
echo":::"
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
# Pi-hole: A black hole for Internet advertisements
# (c) 2015 by Jacob Salmela GPL 2.0
# (c) 2015 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net
# Compiles a list of ad-serving domains by downloading them from multiple sources
piholeIPfile=/tmp/piholeIP
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
#
# 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.
# Run this script as root or under sudo
echo":::"
helpFunc()
{
echo"::: Pull in domains from adlists"
echo":::"
echo"::: Usage: pihole -g"
echo":::"
echo"::: Options:"
echo"::: -f, --force Force lists to be downloaded, even if they don't need updating."
echo"::: -h, --help Show this help dialog"
exit1
}
adListFile=/etc/pihole/adlists.list
adListDefault=/etc/pihole/adlists.default
whitelistScript=/opt/pihole/whitelist.sh
blacklistScript=/opt/pihole/blacklist.sh
#Source the setupVars from install script for the IP
setupVars=/etc/pihole/setupVars.conf
if[[ -f ${setupVars}]];then
. /etc/pihole/setupVars.conf
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 '{print $5}')
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev| awk '{print $4}')
piholeIP=${piholeIPCIDR%/*}
echo"::: WARNING: /etc/pihole/setupVars.conf missing. Possible installation failure."
echo"::: Please run 'pihole -r', and choose the 'install' option to reconfigure."
exit1
fi
# Ad-list sources--one per line in single quotes
# The mahakala source is commented out due to many users having issues with it blocking legitimate domains. Uncomment at your own risk
echo"::: $numberOf unique domains trapped in the event horizon."
}
gravity_hostFormat(){
# Format domain list as "192.168.x.x domain.com"
echo"::: Formatting domains into a HOSTS file..."
if[[ -f /etc/hostname ]];then
hostname=$(</etc/hostname)
elif[ -x "$(command -v hostname)"];then
hostname=$(hostname -f)
else
echo"::: Error: Unable to determine fully qualified domain name of host"
fi
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
if[[ -n "${IPv6_address}"]];then
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
# Otherwise, just create gravity.list as normal using IPv4
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
echo ":::"
echo "::: Options:"
echo "::: -w, whitelist Whitelist domains"
echo "::: -b, blacklist Blacklist domains"
echo "::: -d, debug Start a debugging session if having trouble"
echo "::: -f, flush Flush the pihole.log file"
echo "::: -up, updatePihole Update Pi-hole"
echo "::: -g, updateGravity Update the list of ad-serving domains"
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
echo "::: -c, chronometer Calculates stats and displays to an LCD"
echo "::: -h, help Show this help dialog"
echo "::: -v, version Show current versions"
echo "::: -q, query Query the adlists for a specific domain"
echo "::: uninstall Uninstall Pi-Hole from your system :(!"
exit 0
}
if [[ $# = 0 ]]; then
helpFunc
fi
# Handle redirecting to specific functions based on arguments
case "$1" in
"-w" | "whitelist" ) whitelistFunc "$@";;
"-b" | "blacklist" ) blacklistFunc "$@";;
"-d" | "debug" ) debugFunc;;
"-f" | "flush" ) flushFunc;;
"-up" | "updatePihole" ) updatePiholeFunc;;
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
"-g" | "updateGravity" ) updateGravityFunc "$@";;
"-s" | "setupLCD" ) setupLCDFunction;;
"-c" | "chronometer" ) chronometerFunc "$@";;
"-h" | "help" ) helpFunc;;
"-v" | "version" ) versionFunc;;
"-q" | "query" ) queryFunc "$@";;
"uninstall" ) uninstallFunc;;
* ) helpFunc;;
esac
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.