# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#rootcheck
if[[$EUID -eq 0]];then
echo"::: You are root."
else
echo"::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if[[$(dpkg-query -s sudo)]];then
exportSUDO="sudo"
else
echo"::: Please install sudo or run this script as root."
exit1
fi
fi
if[[$#=0]];then
helpFunc
fi
@ -27,12 +42,19 @@ verbose=true
domList=()
domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
piholeIP=${piholeIPCIDR%/*}
if[[ -f $piholeIPfile]];then
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
piholeIP=$(cat $piholeIPfile)
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
piholeIP=${piholeIPCIDR%/*}
fi
modifyHost=false
@ -54,7 +76,7 @@ function helpFunc()
echo"::: Immediately blacklists one or more domains in the hosts file"
# Continuously append the pihole.log file to the pihole_debug.log file
function dumpPiHoleLog {
trap'{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT
trap'{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#rootcheck
if[[$EUID -eq 0]];then
echo"::: You are root."
else
echo"::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if[[$(dpkg-query -s sudo)]];then
exportSUDO="sudo"
else
echo"::: Please install sudo or run this script as root."
exit1
fi
fi
if[[$#=0]];then
helpFunc
fi
@ -27,12 +42,19 @@ verbose=true
domList=()
domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
piholeIP=${piholeIPCIDR%/*}
if[[ -f $piholeIPfile]];then
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
piholeIP=$(cat $piholeIPfile)
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
piholeIP=${piholeIPCIDR%/*}
fi
modifyHost=false
@ -52,7 +74,7 @@ function helpFunc()
{
echo"::: Immediately whitelists one or more domains in the hosts file"
whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict""It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address."$r$c
#piholeIP is saved to a permanent file so gravity.sh can use it when updating
echo"${IPv4addr%/*}" > /etc/pihole/piholeIP
# Nothing else to do since the variables are already set above
else
# Otherwise, we need to ask the user to input their desired settings.
@ -255,8 +257,8 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
IP address: $IPv4addr
Gateway: $IPv4gw"$r$c)then
# If the settings are correct, then we need to set the piholeIP
# Saving it to a temporary file us to retrieve it later when we run the gravity.sh script
echo"${IPv4addr%/*}" > /tmp/piholeIP
# Saving it to a temporary file us to retrieve it later when we run the gravity.sh script. piholeIP is saved to a permanent file so gravity.sh can use it when updating
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
piholeIP=$(cat $piholeIPfile)
rm $piholeIPfile
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')