# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
backupLegacyPihole
# Display the welcome dialog
# Display the welcome dialog
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer""This installer will transform your Raspberry Pi into a network-wide ad blocker!"$r$c
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer""This installer will transform your Raspberry Pi into a network-wide ad blocker!"$r$c
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed""The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed""The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them."$r$c
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them."$r$c
# Ask if the user wannts to use DHCP settings as their static IP
# Ask if the user wannts to use DHCP settings as their static IP
if(whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
if(whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
@ -119,9 +98,9 @@ if (whiptail --backtitle "Calibrating network interface" --title "Static IP Addr
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
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
# 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.
@ -151,7 +130,6 @@ else
echo$IPv4addr > /tmp/piholeIP
echo$IPv4addr > /tmp/piholeIP
# 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
# If the settings are wrong, the loop continues
# If the settings are wrong, the loop continues
ipSettingsCorrect=False
ipSettingsCorrect=False
@ -174,12 +152,94 @@ else
echo"User canceled."
echo"User canceled."
exit
exit
fi
fi
done
done
# End the if statement for DHCP vs. static
# End the if statement for DHCP vs. static
fi
fi
}
setStaticIPv4()
{
# Append these lines to /etc/dhcpcd.conf to enable a static IP
echo"interface $ethernetDevice
static ip_address=$IPv4addr/24
static routers=$IPv4gw
static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null