choose an interface

also fixing ipv6 logic
This commit is contained in:
Jacob Salmela 2015-11-09 18:33:32 -06:00 committed by dschaper
parent 76c217d9cc
commit ad91eb44fb

View file

@ -63,6 +63,40 @@ whiptail --msgbox --backtitle "Initating network interface" --title "Static IP N
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()
{
# Turn the available interfaces into an array so it can be used with a whiptail dialog
interfacesArray=()
while read -r line
do
interfacesArray+=("$line" "available" "OFF")
done <<< "$availableInterfaces"
# Find out how many interfaces are available to choose from
interfaceCount=$(echo "$availableInterfaces" | wc -l)
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount)
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
for desiredInterface in $chooseInterfaceOptions
do
piholeInterface=$desiredInterface
# case $chooseInterfaceOptions in
# eth0)
# echo "Ethernet"
# useIPv4=true
# ;;
# IPv6)
# echo "IPv6 selected."
# useIPv6=true
# ;;
# esac
# chosenInterface="$desiredInterface"
# echo "$desiredInterface"
echo "Chosen: $piholeInterface"
done
}
use4andor6() use4andor6()
{ {
# Let use select IPv4 and/or IPv6 # Let use select IPv4 and/or IPv6
@ -79,13 +113,18 @@ do
useIPv4=true useIPv4=true
;; ;;
IPv6) IPv6)
echo "IPv6 selected." echo "IPv6 selected."
useIPv6=true useIPv6=true
;; ;;
esac esac
done done
} }
useIPv6dialog()
{
whiptail --msgbox --backtitle "Coming soon..." --title "IPv6 not yet supported" "I need your help for IPv6. Consider donating at: http://pi-hole.net/donate" $r $c
}
getStaticIPv4Settings() getStaticIPv4Settings()
{ {
@ -215,6 +254,8 @@ welcomeDialogs
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way # Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
backupLegacyPihole backupLegacyPihole
chooseInterface
# Let the user decide if they want to block ads over IPv4 and/or IPv6 # Let the user decide if they want to block ads over IPv4 and/or IPv6
use4andor6 use4andor6
@ -224,23 +265,24 @@ if [[ "$useIPv4" = true ]];then
getStaticIPv4Settings getStaticIPv4Settings
setStaticIPv4 setStaticIPv4
else else
useIPv4=false
echo "IPv4 will NOT be used." echo "IPv4 will NOT be used."
fi fi
# Decide is IPv6 will be used # Decide is IPv6 will be used
if [[ "$useIPv6" = true ]];then if [[ "$useIPv6" = true ]];then
whiptail --msgbox --backtitle "Coming soon..." --title "IPv6 not yet supported" "I need your help. Consider donating at: # If only IPv6 is selected, exit because it is not supported yet
if [[ "$useIPv6" = true ]] && [[ "$useIPv4" = false ]];then
http://pi-hole.net/donate" $r $c useIPv6dialog
echo "Using IPv6" exit
else
useIPv6dialog
fi
else else
whiptail --msgbox --backtitle "Coming soon..." --title "IPv6 not yet supported" "I need your help. Consider donating at: useIPv6=false
http://pi-hole.net/donate" $r $c
echo "IPv6 will NOT be used." echo "IPv6 will NOT be used."
fi fi
# Install and log everything to a file # Install and log everything to a file
installPihole | tee $tmpLog installPihole | tee $tmpLog