mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 23:08:07 +00:00
commit
c03268707a
@ -41,6 +41,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
|||||||
[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232)
|
[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232)
|
||||||
|
|
||||||
## Pi-hole Projects
|
## Pi-hole Projects
|
||||||
|
- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||||
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
- [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)
|
- [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/)
|
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
||||||
|
@ -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: #
|
# 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 #
|
||||||
# #
|
# #
|
||||||
@ -32,7 +32,7 @@ http://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/hostsBlockWindowsSpy.txt
|
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hosts/windows10_spy.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
|
||||||
@ -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
|
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||||
#http://spam404bl.com/spam404scamlist.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/)
|
||||||
|
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
||||||
|
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
||||||
|
@ -10,6 +10,21 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
#rootcheck
|
||||||
|
if [[ $EUID -eq 0 ]];then
|
||||||
|
echo "::: You are root."
|
||||||
|
else
|
||||||
|
echo "::: sudo will be used."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the install cannot complete
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
@ -27,12 +42,19 @@ verbose=true
|
|||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
if [[ -f $piholeIPfile ]];then
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
piholeIP=$(cat $piholeIPfile)
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
#rm $piholeIPfile
|
||||||
|
else
|
||||||
|
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||||
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
|
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
fi
|
||||||
|
|
||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
|
||||||
@ -54,7 +76,7 @@ function helpFunc()
|
|||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: sudo pihole -b domain1 [domain2 ...]"
|
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||||
echo "::: Options:"
|
echo "::: Options:"
|
||||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||||
@ -65,6 +87,10 @@ function helpFunc()
|
|||||||
exit 1
|
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/')
|
||||||
@ -166,10 +192,10 @@ function Reload() {
|
|||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP "$dnsmasqPid"
|
$SUDO killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
$SUDO service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,11 @@ function normalChrono(){
|
|||||||
do
|
do
|
||||||
clear
|
clear
|
||||||
# Displays a colorful Pi-hole logo
|
# Displays a colorful Pi-hole logo
|
||||||
toilet -f small -F gay Pi-hole
|
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||||
|
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||||
|
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||||
|
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||||
|
echo ""
|
||||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||||
echo ""
|
echo ""
|
||||||
uptime | cut -d' ' -f11-
|
uptime | cut -d' ' -f11-
|
||||||
|
@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log"
|
|||||||
DNSMASQFILE="/etc/dnsmasq.conf"
|
DNSMASQFILE="/etc/dnsmasq.conf"
|
||||||
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
||||||
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
||||||
|
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
|
||||||
GRAVITYFILE="/etc/pihole/gravity.list"
|
GRAVITYFILE="/etc/pihole/gravity.list"
|
||||||
HOSTSFILE="/etc/hosts"
|
HOSTSFILE="/etc/hosts"
|
||||||
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
||||||
@ -53,6 +54,19 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### Private functions exist here ###
|
### 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 {
|
function compareWhitelist {
|
||||||
if [ ! -f "$WHITELISTMATCHES" ]; then
|
if [ ! -f "$WHITELISTMATCHES" ]; then
|
||||||
$SUDO touch $WHITELISTMATCHES
|
$SUDO touch $WHITELISTMATCHES
|
||||||
@ -126,12 +140,44 @@ function checkProcesses {
|
|||||||
for i in "${PROCESSES[@]}"
|
for i in "${PROCESSES[@]}"
|
||||||
do
|
do
|
||||||
echo "" >> $DEBUG_LOG
|
echo "" >> $DEBUG_LOG
|
||||||
echo -n $i >> "$DEBUG_LOG"
|
echo -n "$i" >> "$DEBUG_LOG"
|
||||||
echo " processes status:" >> $DEBUG_LOG
|
echo " processes status:" >> $DEBUG_LOG
|
||||||
$SUDO systemctl -l status $i >> "$DEBUG_LOG"
|
$SUDO systemctl -l status "$i" >> "$DEBUG_LOG"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ###
|
### END FUNCTIONS ###
|
||||||
|
|
||||||
### Check Pi internet connections ###
|
### Check Pi internet connections ###
|
||||||
@ -148,10 +194,12 @@ echo "Gateway check:" >> $DEBUG_LOG
|
|||||||
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
|
|
||||||
|
versionCheck
|
||||||
compareWhitelist
|
compareWhitelist
|
||||||
compareBlacklist
|
compareBlacklist
|
||||||
testNslookup
|
testNslookup
|
||||||
checkProcesses
|
checkProcesses
|
||||||
|
debugLighttpd
|
||||||
|
|
||||||
echo "::: Writing dnsmasq.conf to debug log..."
|
echo "::: Writing dnsmasq.conf to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
@ -178,7 +226,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
|
|||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
if [ -e "$PIHOLECONFFILE" ]
|
if [ -e "$PIHOLECONFFILE" ]
|
||||||
then
|
then
|
||||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [ ! -z "$line" ]; then
|
if [ ! -z "$line" ]; then
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
[[ "$line" =~ ^#.*$ ]] && continue
|
||||||
@ -191,25 +238,6 @@ else
|
|||||||
printf ":::\tNo 01-pihole.conf file found\n"
|
printf ":::\tNo 01-pihole.conf file found\n"
|
||||||
fi
|
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 "::: Writing size of gravity.list to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
echo "############ gravity.list #############" >> $DEBUG_LOG
|
echo "############ gravity.list #############" >> $DEBUG_LOG
|
||||||
@ -283,7 +311,7 @@ fi
|
|||||||
|
|
||||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
function dumpPiHoleLog {
|
function dumpPiHoleLog {
|
||||||
trap '{ echo -e "\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 -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 "#######################################" >> $DEBUG_LOG
|
||||||
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
||||||
@ -302,7 +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!"
|
||||||
|
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
}
|
}
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
|
@ -10,6 +10,21 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
#rootcheck
|
||||||
|
if [[ $EUID -eq 0 ]];then
|
||||||
|
echo "::: You are root."
|
||||||
|
else
|
||||||
|
echo "::: sudo will be used."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the install cannot complete
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
@ -27,12 +42,19 @@ verbose=true
|
|||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
if [[ -f $piholeIPfile ]];then
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
piholeIP=$(cat $piholeIPfile)
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
#rm $piholeIPfile
|
||||||
|
else
|
||||||
|
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||||
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
|
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
fi
|
||||||
|
|
||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
|
||||||
@ -52,7 +74,7 @@ function helpFunc()
|
|||||||
{
|
{
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: sudo pihole -w domain1 [domain2 ...]"
|
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Options:"
|
echo "::: Options:"
|
||||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||||
@ -64,6 +86,10 @@ function helpFunc()
|
|||||||
exit 1
|
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/')
|
||||||
@ -179,10 +205,10 @@ function Reload() {
|
|||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP "$dnsmasqPid"
|
$SUDO killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
$SUDO service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,16 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
|||||||
# If the URL starts with /admin, it is the Web interface
|
# If the URL starts with /admin, it is the Web interface
|
||||||
$HTTP["url"] =~ "^/admin/" {
|
$HTTP["url"] =~ "^/admin/" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
setenv.add-response-header = (
|
||||||
|
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||||
|
"X-Frame-Options" => "DENY"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the URL does not start with /admin, then it is a query for an ad domain
|
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||||
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||||
# rewrite only js requests
|
# rewrite only js requests
|
||||||
url.rewrite = ("(.*).js" => "pihole/index.js")
|
url.rewrite = ("(.*).js" => "pihole/index.js")
|
||||||
}
|
}
|
||||||
|
@ -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}')
|
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}')
|
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
|
dhcpcdFile=/etc/dhcpcd.conf
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
@ -235,6 +235,8 @@ getStaticIPv4Settings() {
|
|||||||
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.
|
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.
|
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
|
||||||
|
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.
|
||||||
@ -255,8 +257,8 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
|
|||||||
IP address: $IPv4addr
|
IP address: $IPv4addr
|
||||||
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
|
# 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%/*}" > /tmp/piholeIP
|
echo "${IPv4addr%/*}" > /etc/pihole/piholeIP
|
||||||
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
|
||||||
@ -546,7 +548,7 @@ checkForDependencies() {
|
|||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking dependencies:"
|
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 )
|
||||||
for i in "${dependencies[@]}"; do
|
for i in "${dependencies[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||||
|
@ -44,7 +44,7 @@ function removeAndPurge {
|
|||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common
|
# 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
|
for i in "${dependencies[@]}"; do
|
||||||
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
||||||
while true; do
|
while true; do
|
||||||
|
@ -27,7 +27,7 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
piholeIPfile=/tmp/piholeIP
|
piholeIPfile=/etc/pihole/piholeIP
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
adListFile=/etc/pihole/adlists.list
|
adListFile=/etc/pihole/adlists.list
|
||||||
@ -38,7 +38,7 @@ blacklistScript=/opt/pihole/blacklist.sh
|
|||||||
if [[ -f $piholeIPfile ]];then
|
if [[ -f $piholeIPfile ]];then
|
||||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||||
piholeIP=$(cat $piholeIPfile)
|
piholeIP=$(cat $piholeIPfile)
|
||||||
rm $piholeIPfile
|
#rm $piholeIPfile
|
||||||
else
|
else
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
@ -320,7 +320,7 @@ function gravity_reload() {
|
|||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
$SUDO kill -HUP "$dnsmasqPid"
|
$SUDO killall -s HUP dnsmasq
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start
|
$SUDO service dnsmasq start
|
||||||
|
Loading…
Reference in New Issue
Block a user