# 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?
@ -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
@ -177,9 +155,91 @@ else
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