mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Cleaned code and added prompt for purge on uninstall
This commit is contained in:
parent
0b5f005a5d
commit
0b9e78df2c
6 changed files with 100 additions and 100 deletions
|
@ -33,13 +33,11 @@ versbose=true
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
|
|
||||||
piholeIPfile=/tmp/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
|
# 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)}')
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
|
||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
@ -53,10 +51,10 @@ 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/')
|
||||||
|
|
||||||
if [ -z "$validDomain" ]; then
|
if [ -z "$validDomain" ]; then
|
||||||
echo $1 is not a valid argument or domain name
|
echo "$1" is not a valid argument or domain name
|
||||||
else
|
else
|
||||||
domList=("${domList[@]}" $validDomain)
|
domList=("${domList[@]}" $validDomain)
|
||||||
fi
|
fi
|
||||||
|
@ -69,10 +67,10 @@ function PopBlacklistFile(){
|
||||||
fi
|
fi
|
||||||
for dom in "${domList[@]}"
|
for dom in "${domList[@]}"
|
||||||
do
|
do
|
||||||
if $addmode; then
|
if "$addmode"; then
|
||||||
AddDomain $dom
|
AddDomain "$dom"
|
||||||
else
|
else
|
||||||
RemoveDomain $dom
|
RemoveDomain "$dom"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -86,7 +84,7 @@ function AddDomain(){
|
||||||
if $versbose; then
|
if $versbose; then
|
||||||
echo -n "::: Adding $1 to blacklist file..."
|
echo -n "::: Adding $1 to blacklist file..."
|
||||||
fi
|
fi
|
||||||
echo $1 >> $blacklist
|
echo "$1" >> $blacklist
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
|
@ -119,14 +117,14 @@ function ModifyHostFile(){
|
||||||
if $addmode; then
|
if $addmode; then
|
||||||
#add domains to the hosts file
|
#add domains to the hosts file
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r $blacklist ]];then
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
numberOf=$($blacklist | sed '/^\s*$/d' | wc -l)
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n $piholeIPv6 ]];then
|
||||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
$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
|
$blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -138,10 +136,10 @@ function ModifyHostFile(){
|
||||||
#we need to remove the domains from the blacklist file and the host file
|
#we need to remove the domains from the blacklist file and the host file
|
||||||
echo "::: $dom"
|
echo "::: $dom"
|
||||||
echo -n "::: removing from HOSTS file..."
|
echo -n "::: removing from HOSTS file..."
|
||||||
echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo -n "::: removing from blackist.txt..."
|
echo -n "::: removing from blackist.txt..."
|
||||||
echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
||||||
echo " done!"
|
echo " done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -157,7 +155,7 @@ function Reload() {
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP $dnsmasqPid
|
sudo kill -HUP "$dnsmasqPid"
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
sudo service dnsmasq start
|
||||||
|
@ -174,7 +172,7 @@ do
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) versbose=false;;
|
||||||
* ) HandleOther $var;;
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ function CalcBlockedDomains(){
|
||||||
|
|
||||||
function CalcQueriesToday(){
|
function CalcQueriesToday(){
|
||||||
if [ -e "$piLog" ];then
|
if [ -e "$piLog" ];then
|
||||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
queriesToday=$("$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
queriesToday="Err."
|
queriesToday="Err."
|
||||||
fi
|
fi
|
||||||
|
@ -43,7 +43,7 @@ function CalcQueriesToday(){
|
||||||
|
|
||||||
function CalcblockedToday(){
|
function CalcblockedToday(){
|
||||||
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
||||||
blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
blockedToday=$($piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
blockedToday="Err."
|
blockedToday="Err."
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -33,12 +33,11 @@ versbose=true
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
piholeIPfile=/tmp/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
|
# 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)}')
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
|
|
||||||
modifyHost=false
|
modifyHost=false
|
||||||
|
@ -52,7 +51,7 @@ 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/')
|
||||||
|
|
||||||
if [ -z "$validDomain" ]; then
|
if [ -z "$validDomain" ]; then
|
||||||
echo "::: $1 is not a valid argument or domain name"
|
echo "::: $1 is not a valid argument or domain name"
|
||||||
|
@ -69,9 +68,9 @@ function PopWhitelistFile(){
|
||||||
for dom in "${domList[@]}"
|
for dom in "${domList[@]}"
|
||||||
do
|
do
|
||||||
if $addmode; then
|
if $addmode; then
|
||||||
AddDomain $dom
|
AddDomain "$dom"
|
||||||
else
|
else
|
||||||
RemoveDomain $dom
|
RemoveDomain "$dom"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -86,7 +85,7 @@ function AddDomain(){
|
||||||
if $versbose; then
|
if $versbose; then
|
||||||
echo -n "::: Adding $1 to whitelist.txt..."
|
echo -n "::: Adding $1 to whitelist.txt..."
|
||||||
fi
|
fi
|
||||||
echo $1 >> $whitelist
|
echo "$1" >> $whitelist
|
||||||
modifyHost=true
|
modifyHost=true
|
||||||
if $versbose; then
|
if $versbose; then
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
@ -122,12 +121,12 @@ function ModifyHostFile(){
|
||||||
#remove domains in from hosts file
|
#remove domains in from hosts file
|
||||||
if [[ -r $whitelist ]];then
|
if [[ -r $whitelist ]];then
|
||||||
# Remove whitelist entries
|
# Remove whitelist entries
|
||||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
numberOf=$($whitelist | sed '/^\s*$/d' | wc -l)
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
||||||
awk -F':' '{print $1}' $whitelist | while read line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
|
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
|
||||||
awk -F':' '{print $1}' $whitelist | while read line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
|
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
|
||||||
echo "l" >> /etc/pihole/whitelist.tmp
|
echo "l" >> /etc/pihole/whitelist.tmp
|
||||||
grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp
|
grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp
|
||||||
rm /etc/pihole/gravity.list
|
rm /etc/pihole/gravity.list
|
||||||
|
@ -144,15 +143,15 @@ function ModifyHostFile(){
|
||||||
do
|
do
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n $piholeIPv6 ]];then
|
||||||
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..."
|
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..."
|
||||||
echo $rdom | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo -n "::: Un-whitelisting $rdom on IPv4"
|
echo -n "::: Un-whitelisting $rdom on IPv4"
|
||||||
echo $rdom | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
echo -n "::: Removing $rdom from whitelist.txt..."
|
echo -n "::: Removing $rdom from whitelist.txt..."
|
||||||
echo $rdom| sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
||||||
echo " done!"
|
echo " done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -166,7 +165,7 @@ function Reload() {
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP $dnsmasqPid
|
sudo kill -HUP "$dnsmasqPid"
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
sudo service dnsmasq start
|
||||||
|
@ -183,7 +182,7 @@ do
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) versbose=false;;
|
||||||
* ) HandleOther $var;;
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ c=$(( columns / 2 ))
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
|
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
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)
|
||||||
|
@ -63,13 +63,13 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
### Nate 3/26/2016 - Why are we declaring upgrade here? It isn't global (nor is it used anywhere else)
|
||||||
if [ -d "/etc/pihole" ]; then
|
# if [ -d "/etc/pihole" ]; then
|
||||||
# Likely an existing install
|
# # Likely an existing install
|
||||||
upgrade=true
|
# upgrade=true
|
||||||
else
|
# else
|
||||||
upgrade=false
|
# upgrade=false
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html
|
###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html
|
||||||
|
@ -78,10 +78,10 @@ spinner() {
|
||||||
|
|
||||||
spin='-\|/'
|
spin='-\|/'
|
||||||
i=0
|
i=0
|
||||||
while $SUDO kill -0 $pid 2>/dev/null
|
while $SUDO kill -0 "$pid" 2>/dev/null
|
||||||
do
|
do
|
||||||
i=$(( (i+1) %4 ))
|
i=$(( (i+1) %4 ))
|
||||||
printf "\b${spin:$i:1}"
|
printf "\b%s" "{$spin:$i:1}"
|
||||||
sleep .1
|
sleep .1
|
||||||
done
|
done
|
||||||
printf "\b"
|
printf "\b"
|
||||||
|
@ -92,12 +92,12 @@ backupLegacyPihole() {
|
||||||
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
||||||
echo "::: Original Pi-hole detected. Initiating sub space transport"
|
echo "::: Original Pi-hole detected. Initiating sub space transport"
|
||||||
$SUDO mkdir -p /etc/pihole/original/
|
$SUDO mkdir -p /etc/pihole/original/
|
||||||
$SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d")
|
$SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")"
|
||||||
$SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d")
|
$SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")"
|
||||||
$SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d")
|
$SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")"
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d")
|
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")"
|
||||||
$SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d")
|
$SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")"
|
||||||
$SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d")
|
$SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")"
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
|
@ -120,9 +120,9 @@ verifyFreeDiskSpace() {
|
||||||
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
|
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
|
||||||
requiredFreeBytes=51200
|
requiredFreeBytes=51200
|
||||||
|
|
||||||
existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
existingFreeBytes=$(df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1)
|
||||||
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
|
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
|
||||||
existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
existingFreeBytes=$(df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
|
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
|
||||||
|
@ -158,7 +158,7 @@ chooseInterface() {
|
||||||
do
|
do
|
||||||
piholeInterface=$desiredInterface
|
piholeInterface=$desiredInterface
|
||||||
echo "::: Using interface: $piholeInterface"
|
echo "::: Using interface: $piholeInterface"
|
||||||
echo ${piholeInterface} > /tmp/piholeINT
|
echo "${piholeInterface}" > /tmp/piholeINT
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "::: Cancel selected, exiting...."
|
echo "::: Cancel selected, exiting...."
|
||||||
|
@ -169,7 +169,7 @@ chooseInterface() {
|
||||||
|
|
||||||
cleanupIPv6() {
|
cleanupIPv6() {
|
||||||
# Removes IPv6 indicator file if we are not using IPv6
|
# Removes IPv6 indicator file if we are not using IPv6
|
||||||
if [ -f "/etc/pihole/.useIPv6" ] && [ ! $useIPv6 ]; then
|
if [ -f "/etc/pihole/.useIPv6" ] && [ ! "$useIPv6" ]; then
|
||||||
rm /etc/pihole/.useIPv6
|
rm /etc/pihole/.useIPv6
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -244,11 +244,11 @@ getStaticIPv4Settings() {
|
||||||
until [[ $ipSettingsCorrect = True ]]
|
until [[ $ipSettingsCorrect = True ]]
|
||||||
do
|
do
|
||||||
# Ask for the IPv4 address
|
# Ask for the IPv4 address
|
||||||
IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c $IPv4addr 3>&1 1>&2 2>&3)
|
IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
echo "::: Your static IPv4 address: $IPv4addr"
|
echo "::: Your static IPv4 address: $IPv4addr"
|
||||||
# Ask for the gateway
|
# Ask for the gateway
|
||||||
IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c $IPv4gw 3>&1 1>&2 2>&3)
|
IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
echo "::: Your static IPv4 gateway: $IPv4gw"
|
echo "::: Your static IPv4 gateway: $IPv4gw"
|
||||||
# Give the user a chance to review their settings before moving on
|
# Give the user a chance to review their settings before moving on
|
||||||
|
@ -257,8 +257,8 @@ getStaticIPv4Settings() {
|
||||||
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
|
||||||
echo ${IPv4addr%/*} > /tmp/piholeIP
|
echo "${IPv4addr%/*}" > /tmp/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
|
||||||
else
|
else
|
||||||
|
@ -292,12 +292,12 @@ setDHCPCD() {
|
||||||
|
|
||||||
setStaticIPv4() {
|
setStaticIPv4() {
|
||||||
# Tries to set the IPv4 address
|
# Tries to set the IPv4 address
|
||||||
if grep -q $IPv4addr $dhcpcdFile; then
|
if grep -q "$IPv4addr" $dhcpcdFile; then
|
||||||
# address already set, noop
|
# address already set, noop
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
setDHCPCD
|
setDHCPCD
|
||||||
$SUDO ip addr replace dev $piholeInterface $IPv4addr
|
$SUDO ip addr replace dev "$piholeInterface" "$IPv4addr"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
@ -377,14 +377,14 @@ setDNS(){
|
||||||
|
|
||||||
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3)
|
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
piholeDNS1=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
||||||
piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
piholeDNS2=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
||||||
|
|
||||||
if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then
|
if ! valid_ip "$piholeDNS1" || [ ! "$piholeDNS1" ]; then
|
||||||
piholeDNS1=$strInvalid
|
piholeDNS1=$strInvalid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then
|
if ! valid_ip "$piholeDNS2" && [ "$piholeDNS2" ]; then
|
||||||
piholeDNS2=$strInvalid
|
piholeDNS2=$strInvalid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -393,14 +393,14 @@ setDNS(){
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then
|
if [[ $piholeDNS1 == "$strInvalid" ]] || [[ $piholeDNS2 == "$strInvalid" ]]; then
|
||||||
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c
|
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c
|
||||||
|
|
||||||
if [[ $piholeDNS1 == $strInvalid ]]; then
|
if [[ $piholeDNS1 == "$strInvalid" ]]; then
|
||||||
piholeDNS1=""
|
piholeDNS1=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $piholeDNS2 == $strInvalid ]]; then
|
if [[ $piholeDNS2 == "$strInvalid" ]]; then
|
||||||
piholeDNS2=""
|
piholeDNS2=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ checkForDependencies() {
|
||||||
# it needs to have been run at least once on new installs!
|
# it needs to have been run at least once on new installs!
|
||||||
|
|
||||||
timestamp=$(stat -c %Y /var/cache/apt/)
|
timestamp=$(stat -c %Y /var/cache/apt/)
|
||||||
timestampAsDate=$(date -d @$timestamp "+%b %e")
|
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
if [ ! "$today" == "$timestampAsDate" ]; then
|
||||||
|
@ -540,9 +540,9 @@ checkForDependencies() {
|
||||||
do
|
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
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
$SUDO apt-get -y -qq install $i > /dev/null & spinner $!
|
$SUDO apt-get -y -qq install "$i" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
|
@ -583,7 +583,7 @@ is_repo() {
|
||||||
make_repo() {
|
make_repo() {
|
||||||
# Remove the non-repod interface and clone the interface
|
# Remove the non-repod interface and clone the interface
|
||||||
echo -n "::: Cloning $2 into $1..."
|
echo -n "::: Cloning $2 into $1..."
|
||||||
$SUDO rm -rf $1
|
$SUDO rm -rf "$1"
|
||||||
$SUDO git clone -q "$2" "$1" > /dev/null & spinner $!
|
$SUDO git clone -q "$2" "$1" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
@ -591,7 +591,7 @@ make_repo() {
|
||||||
update_repo() {
|
update_repo() {
|
||||||
# Pull the latest commits
|
# Pull the latest commits
|
||||||
echo -n "::: Updating repo in $1..."
|
echo -n "::: Updating repo in $1..."
|
||||||
cd "$1"
|
cd "$1" || exit
|
||||||
$SUDO git pull -q > /dev/null & spinner $!
|
$SUDO git pull -q > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,16 @@ fi
|
||||||
|
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
$SUDO apt-get -y remove --purge dnsutils bc toilet
|
read -p "Do you wish to purge PiHole's dependencies from your OS?\n WARNING: This is destructive if run on any non-Debian based OS \n(SAFE TO RUN ON RASPBIAN)" -n 1 -r
|
||||||
$SUDO apt-get -y remove --purge dnsmasq
|
echo
|
||||||
$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
if [[ $REPLY =~ ^{Yy]$ ]]; then
|
||||||
|
$SUDO apt-get -y remove --purge dnsutils bc toilet
|
||||||
|
$SUDO apt-get -y remove --purge dnsmasq
|
||||||
|
$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
||||||
|
|
||||||
|
echo "Removing dnsmasq config files..."
|
||||||
|
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
|
fi
|
||||||
|
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
# Only web directories/files that are created by pihole should be removed.
|
||||||
echo "Removing the Pi-hole Web server files..."
|
echo "Removing the Pi-hole Web server files..."
|
||||||
|
@ -42,9 +49,6 @@ if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||||
$SUDO rm -rf /var/www/html
|
$SUDO rm -rf /var/www/html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing dnsmasq config files..."
|
|
||||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
# to guarantee no additional changes were made to /etc/crontab after
|
# to guarantee no additional changes were made to /etc/crontab after
|
||||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||||
|
@ -63,7 +67,6 @@ if [[ -f /etc/cron.d/pihole ]];then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing config files and scripts..."
|
echo "Removing config files and scripts..."
|
||||||
$SUDO rm /etc/dnsmasq.conf
|
|
||||||
$SUDO rm -rf /etc/lighttpd/
|
$SUDO rm -rf /etc/lighttpd/
|
||||||
$SUDO rm /var/log/pihole.log
|
$SUDO rm /var/log/pihole.log
|
||||||
$SUDO rm /usr/local/bin/gravity.sh
|
$SUDO rm /usr/local/bin/gravity.sh
|
||||||
|
|
46
gravity.sh
46
gravity.sh
|
@ -41,7 +41,7 @@ if [[ -f $piholeIPfile ]];then
|
||||||
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)}')
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -54,18 +54,19 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# Variables for various stages of downloading and formatting the list
|
# Variables for various stages of downloading and formatting the list
|
||||||
|
## Nate 3/26/2016 - Commented unused variables
|
||||||
basename=pihole
|
basename=pihole
|
||||||
piholeDir=/etc/$basename
|
piholeDir=/etc/$basename
|
||||||
adList=$piholeDir/gravity.list
|
adList=$piholeDir/gravity.list
|
||||||
blacklist=$piholeDir/blacklist.txt
|
#blacklist=$piholeDir/blacklist.txt
|
||||||
whitelist=$piholeDir/whitelist.txt
|
#whitelist=$piholeDir/whitelist.txt
|
||||||
latentWhitelist=$piholeDir/latentWhitelist.txt
|
#latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||||
justDomainsExtension=domains
|
justDomainsExtension=domains
|
||||||
matterandlight=$basename.0.matterandlight.txt
|
matterandlight=$basename.0.matterandlight.txt
|
||||||
supernova=$basename.1.supernova.txt
|
supernova=$basename.1.supernova.txt
|
||||||
eventHorizon=$basename.2.eventHorizon.txt
|
eventHorizon=$basename.2.eventHorizon.txt
|
||||||
accretionDisc=$basename.3.accretionDisc.txt
|
accretionDisc=$basename.3.accretionDisc.txt
|
||||||
eyeOfTheNeedle=$basename.4.wormhole.txt
|
#eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
# After setting defaults, check if there's local overrides
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
if [[ -r $piholeDir/pihole.conf ]];then
|
||||||
|
@ -76,19 +77,18 @@ fi
|
||||||
|
|
||||||
spinner(){
|
spinner(){
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.001
|
|
||||||
local spinstr='/-\|'
|
|
||||||
|
|
||||||
spin='-\|/'
|
spin='-\|/'
|
||||||
i=0
|
i=0
|
||||||
while $SUDO kill -0 $pid 2>/dev/null
|
while $SUDO kill -0 "$pid" 2>/dev/null
|
||||||
do
|
do
|
||||||
i=$(( (i+1) %4 ))
|
i=$(( (i+1) %4 ))
|
||||||
printf "\b${spin:$i:1}"
|
printf "\b%s" "${spin:$i:1}"
|
||||||
sleep .1
|
sleep .1
|
||||||
done
|
done
|
||||||
printf "\b"
|
printf "\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# collapse - begin formation of pihole
|
# collapse - begin formation of pihole
|
||||||
function gravity_collapse() {
|
function gravity_collapse() {
|
||||||
|
@ -99,7 +99,7 @@ function gravity_collapse() {
|
||||||
#custom file found, use this instead of default
|
#custom file found, use this instead of default
|
||||||
echo -n "::: Custom adList file detected. Reading..."
|
echo -n "::: Custom adList file detected. Reading..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
|
@ -112,7 +112,7 @@ function gravity_collapse() {
|
||||||
#no custom file found, use defaults!
|
#no custom file found, use defaults!
|
||||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
|
@ -146,7 +146,7 @@ function gravity_patternCheck() {
|
||||||
# Some of the blocklists are copyright, they need to be downloaded
|
# Some of the blocklists are copyright, they need to be downloaded
|
||||||
# and stored as is. They can be processed for content after they
|
# and stored as is. They can be processed for content after they
|
||||||
# have been saved.
|
# have been saved.
|
||||||
cp $patternBuffer $saveLocation
|
cp "$patternBuffer" "$saveLocation"
|
||||||
echo " List updated, transport successful!"
|
echo " List updated, transport successful!"
|
||||||
else
|
else
|
||||||
# curl didn't download any host files, probably because of the date check
|
# curl didn't download any host files, probably because of the date check
|
||||||
|
@ -169,12 +169,12 @@ function gravity_transport() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Silently curl url
|
# Silently curl url
|
||||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
curl -s "$cmd_ext" "$heisenbergCompensator" -A "$agent" "$url" > "$patternBuffer"
|
||||||
# Check for list updates
|
# Check for list updates
|
||||||
gravity_patternCheck $patternBuffer
|
gravity_patternCheck "$patternBuffer"
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -f $patternBuffer
|
rm -f "$patternBuffer"
|
||||||
}
|
}
|
||||||
|
|
||||||
# spinup - main gravity function
|
# spinup - main gravity function
|
||||||
|
@ -222,7 +222,7 @@ function gravity_Schwarzchild() {
|
||||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matterandlight
|
"$i" |tr -d '\r' >> $piholeDir/$matterandlight
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ function gravity_Whitelist() {
|
||||||
echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..."
|
echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..."
|
||||||
|
|
||||||
urls=()
|
urls=()
|
||||||
for url in ${sources[@]}
|
for url in "${sources[@]}"
|
||||||
do
|
do
|
||||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
||||||
urls=("${urls[@]}" $tmp)
|
urls=("${urls[@]}" $tmp)
|
||||||
|
@ -257,7 +257,7 @@ function gravity_Whitelist() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||||
$whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $!
|
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $!
|
||||||
|
|
||||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||||
|
@ -283,13 +283,13 @@ function gravity_hostFormat() {
|
||||||
if [[ -n $piholeIPv6 ]];then
|
if [[ -n $piholeIPv6 ]];then
|
||||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
||||||
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
$piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
||||||
|
|
||||||
else
|
else
|
||||||
# Otherwise, just create gravity.list as normal using IPv4
|
# Otherwise, just create gravity.list as normal using IPv4
|
||||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
||||||
echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
$piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
||||||
fi
|
fi
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
cp $piholeDir/$accretionDisc $adList
|
cp $piholeDir/$accretionDisc $adList
|
||||||
|
@ -301,10 +301,10 @@ function gravity_blackbody() {
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in $piholeDir/*.$justDomainsExtension
|
||||||
do
|
do
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
rm -f $file
|
rm -f "$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ function gravity_reload() {
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
$SUDO kill -HUP "$dnsmasqPid" & spinner $!
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
$SUDO service dnsmasq start & spinner $!
|
$SUDO service dnsmasq start & spinner $!
|
||||||
|
|
Loading…
Reference in a new issue