###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html
###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html
spinner(){
spinner(){
localpid=$1
localpid=$1
spin='-\|/'
spin='-\|/'
@ -86,10 +87,8 @@ spinner(){
printf"\b"
printf"\b"
}
}
backupLegacyPihole(){
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
backupLegacyPihole(){
if[[ -f /etc/dnsmasq.d/adList.conf ]];then
if[[ -f /etc/dnsmasq.d/adList.conf ]];then
echo"Original Pi-hole detected. Initiating sub space transport"
echo"Original Pi-hole detected. Initiating sub space transport"
$SUDO mkdir -p /etc/pihole/original/
$SUDO mkdir -p /etc/pihole/original/
@ -104,7 +103,7 @@ backupLegacyPihole(){
fi
fi
}
}
welcomeDialogs(){
welcomeDialogs(){
# 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
@ -116,8 +115,8 @@ welcomeDialogs(){
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
}
}
chooseInterface(){
chooseInterface(){
# Turn the available interfaces into an array so it can be used with a whiptail dialog
# Turn the available interfaces into an array so it can be used with a whiptail dialog
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
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
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported""$piholeIPv6 will be used to block ads."$r$c
$SUDO touch /etc/pihole/.useIPv6
$SUDO touch /etc/pihole/.useIPv6
}
}
getStaticIPv4Settings(){
getStaticIPv4Settings(){
# Ask if the user wants to use DHCP settings as their static IP
# Ask if the user wants 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?
IP address: $IPv4addr
IP address: $IPv4addr
@ -245,15 +245,16 @@ getStaticIPv4Settings(){
fi
fi
}
}
setDHCPCD(){
setDHCPCD(){
#Append these lines to dhcpcd.conf to enable a static IP
#Append these lines to dhcpcd.conf to enable a static IP
echo"interface $piholeInterface
echo"interface $piholeInterface
static ip_address=$IPv4addr
static ip_address=$IPv4addr
static routers=$IPv4gw
static routers=$IPv4gw
static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null
static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null
}
}
setStaticIPv4(){
setStaticIPv4(){
# Tries to set the IPv4 address
if grep -q $IPv4addr$dhcpcdFile;then
if grep -q $IPv4addr$dhcpcdFile;then
# address already set, noop
# address already set, noop
:
:
@ -266,7 +267,8 @@ setStaticIPv4(){
fi
fi
}
}
installScripts(){
installScripts(){
# Install the scripts from /etc/.pihole to their various locations