Fix logic bug in `setup_user`, update how setupVars are sourced so they will only be used if the user selects `update` and not if they select `install`.
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
IPv4_address=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
}
@ -138,13 +141,13 @@ get_available_interfaces() {
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}
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer""\n\nThis installer will transform your device into a network-wide ad blocker!" ${r}${c}
# Support for a part-time dev
whiptail --msgbox --backtitle "Plea" --title "Free and open source""The Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" ${r}${c}
whiptail --msgbox --backtitle "Plea" --title "Free and open source""\n\nThe Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" ${r}${c}
# Explain the need for a static address
whiptail --msgbox --backtitle "Initiating 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 "Initiating network interface" --title "Static IP Needed""\n\nThe 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}
}
@ -219,10 +222,18 @@ chooseInterface() {
echo"::: Cancel selected, exiting...."
exit1
fi
}
useIPv6dialog(){
# Show the IPv6 address used for blocking
IPv6_address=$(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""$IPv6_address will be used to block ads."${r}${c}
}
use4andor6(){
local useIPv4
local useIPv6
# Let use select IPv4 and/or IPv6
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)"${r}${c} 2)
options=(IPv4 "Block ads over IPv4" on
@ -236,47 +247,31 @@ use4andor6() {
IPv6 )useIPv6=true;;
esac
done
if[${useIPv4}]&&[ ! ${useIPv6}];then
getStaticIPv4Settings
setStaticIPv4
echo"::: Using IPv4 on $IPv4addr"
echo"::: IPv6 will NOT be used."
fi
if[ ! ${useIPv4}]&&[${useIPv6}];then
useIPv6dialog
echo"::: IPv4 will NOT be used."
echo"::: Using IPv6 on $piholeIPv6"
fi
if[${useIPv4}]&&[${useIPv6}];then
getStaticIPv4Settings
setStaticIPv4
useIPv6dialog
echo"::: Using IPv4 on $IPv4addr"
echo"::: Using IPv6 on $piholeIPv6"
if[[${useIPv4}]];then
find_IPv4_information
getStaticIPv4Settings
setStaticIPv4
fi
if[[${useIPv6}]];then
useIPv6dialog
fi
echo"::: IPv4 address: ${IPv4_address}"
echo"::: IPv6 address: ${IPv6_address}"
if[ ! ${useIPv4}]&&[ ! ${useIPv6}];then
echo"::: Cannot continue, neither IPv4 or IPv6 selected"
echo"::: Exiting"
exit1
fi
else
echo"::: Cancel selected. Exiting..."
exit1
fi
}
useIPv6dialog(){
# Show the IPv6 address used for blocking
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}
}
getStaticIPv4Settings(){
# 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?
IP address: $IPv4addr
IP address: $IPv4_address
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.
@ -290,16 +285,16 @@ It is also possible to use a DHCP reservation, but if you are going to do that,