availableInterfaces=$(ip link show | awk -F' ''/[0-9]: [a-z]/ {print $2}'| grep -v "lo"| cut -d':' -f1)
dhcpcdFile=/etc/dhcpcd.conf
####### FUCNTIONS ##########
@ -51,7 +52,113 @@ else
fi
}
set_static_ip()
welcomeDialogs()
{
# 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
# Explain the need for a static address
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
# 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?
IP address: $IPv4addr
Subnet mask: $IPv4mask
Gateway: $IPv4gw"$r$c) then
# 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.
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
# Nothing else to do since the variables are already set above
else
# Otherwise, we need to ask the user to input their desired settings.
# Start by getting the IPv4 address (pre-filling it with info gathered from DHCP)
# Start a loop to let the user enter their information with the chance to go back and edit it if necessary
# 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
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer""This installer will transform your Raspberry Pi into a network-wide ad blocker!"$r$c
# Explain the need for a static address
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.
# Let the user decide if they want to block ads over IPv4 and/or IPv6
use4andor6
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
if(whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
IP address: $IPv4addr
Subnet mask: $IPv4mask
Gateway: $IPv4gw"$r$c) then
# 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.
# Decide is IPv4 will be used
if[["$useIPv4"=true]];then
echo"Using IPv4"
getStaticIPv4Settings
setStaticIPv4
else
echo"IPv4 will NOT be used."
fi
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
# Decide is IPv6 will be used
if[["$useIPv6"=true]];then
whiptail --msgbox --backtitle "Coming soon..." --title "IPv6 not yet supported""I need your help. Consider donating at:
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
http://pi-hole.net/donate"$r$c
echo"Using IPv6"
else
# Otherwise, we need to ask the user to input their desired settings.
# Start by getting the IPv4 address (pre-filling it with info gathered from DHCP)
# Start a loop to let the user enter their information with the chance to go back and edit it if necessary