# 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.
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 --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
[sudo mkdir /var/www/html/pihole]='Making a directory for the Web interface...'
[sudo curl -o /var/www/html/pihole/index.html https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html]='Installing a blank HTML page to take place of ads...'
[sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip]='Downloading the Pi-hole dashboard...'
[sudo unzip /var/www/master.zip -d /var/www/html/]='Unpacking the dashboard...'
[sudo mv /var/www/html/AdminLTE-master /var/www/html/admin]='Renaming the dashboard...'
[sudo rm /var/www/master.zip 2>/dev/null]='Cleaning up the dashboard temp files...'
[sudo touch /var/log/pihole.log]='Creating a log file for the Pi-hole...'
[sudo chmod 644 /var/log/pihole.log]='Making sure the log is readable...'
[sudo chown dnsmasq:root /var/log/pihole.log]='Letting dnsmasq see the log file so stats can be displayed...'