cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)"${r}${c} 2)
@ -249,7 +241,7 @@ use4andor6() {
echo"::: Exiting"
exit1
fi
cleanupIPv6
else
echo"::: Cancel selected. Exiting..."
exit1
@ -260,8 +252,6 @@ useIPv6dialog() {
# Show the IPv6 address used for blocking
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported""$piholeIPv6 will be used to block ads."${r}${c}
${SUDO} touch /etc/pihole/.useIPv6
}
getStaticIPv4Settings(){
@ -273,8 +263,6 @@ 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.
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
# Nothing else to do since the variables are already set above
else
# Otherwise, we need to ask the user to input their desired settings.
@ -294,10 +282,6 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
if(whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct?
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. piholeIP is saved to a permanent file so gravity.sh can use it when updating
$SUDOecho"${IPv4addr%/*}" > /etc/pihole/piholeIP
$SUDOecho"$piholeInterface" > /tmp/piholeINT
# After that's done, the loop ends and we move on
ipSettingsCorrect=True
else
@ -358,6 +342,9 @@ setStaticIPv4() {
${SUDO}echo"ONBOOT=yes" >> ${IFCFG_FILE}
${SUDO}echo"IPADDR=$IPADDR" >> ${IFCFG_FILE}
${SUDO}echo"PREFIX=$CIDR" >> ${IFCFG_FILE}
${SUDO}echo"GATEWAY=$IPv4gw" >> ${IFCFG_FILE}
${SUDO}echo"DNS1=$piholeDNS1" >> ${IFCFG_FILE}
${SUDO}echo"DNS2=$piholeDNS2" >> ${IFCFG_FILE}
${SUDO}echo"USERCTL=no" >> ${IFCFG_FILE}
${SUDO} ip addr replace dev "$piholeInterface""$IPv4addr"
# 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
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
#Source the setupVars from install script for the IP
. /etc/pihole/setupVars.conf
#Remove the /* from the end of the IPv4addr.
IPv4addr=${IPv4addr%/*}
# Variables for various stages of downloading and formatting the list
## Nate 3/26/2016 - Commented unused variables
basename=pihole
piholeDir=/etc/${basename}
adList=${piholeDir}/gravity.list
#blacklist=$piholeDir/blacklist.txt
#whitelist=$piholeDir/whitelist.txt
#latentWhitelist=$piholeDir/latentWhitelist.txt
justDomainsExtension=domains
matterandlight=${basename}.0.matterandlight.txt
matterAndLight=${basename}.0.matterandlight.txt
supernova=${basename}.1.supernova.txt
eventHorizon=${basename}.2.eventHorizon.txt
accretionDisc=${basename}.3.accretionDisc.txt
#eyeOfTheNeedle=$basename.4.wormhole.txt
# After setting defaults, check if there's local overrides
if[[ -r ${piholeDir}/pihole.conf ]];then
@ -213,10 +195,10 @@ function gravity_Schwarzchild() {
echo"::: "
# Find all active domains and compile them into one file and remove CRs
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 ${piholeIPv6}]];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)