mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 17:13:17 +00:00
Reverted back to ip behaviour - not only is ifconfig deprecated but so is its "labels" feature. Better to support modern labelless binding of multiple addresses.
This commit is contained in:
parent
34913941da
commit
66b9d07bcb
1 changed files with 37 additions and 14 deletions
|
@ -37,9 +37,7 @@ r=$(( rows / 2 ))
|
||||||
c=$(( columns / 2 ))
|
c=$(( columns / 2 ))
|
||||||
|
|
||||||
|
|
||||||
# All interfaces, including single physical interfaces with multiple IPs / "labels".
|
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1)
|
||||||
# While deprecated, ifconfig seems to differentiate between labels better than ip does.
|
|
||||||
availableInterfaces=$(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d')
|
|
||||||
dhcpcdFile=/etc/dhcpcd.conf
|
dhcpcdFile=/etc/dhcpcd.conf
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
|
@ -149,24 +147,49 @@ chooseInterface() {
|
||||||
interfaceCount=$(echo "$availableInterfaces" | wc -l)
|
interfaceCount=$(echo "$availableInterfaces" | wc -l)
|
||||||
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount)
|
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount)
|
||||||
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
|
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
|
||||||
if [[ $? = 0 ]];then
|
if [[ ! ($? = 0) ]];then
|
||||||
|
echo "::: Cancel selected, exiting...."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
for desiredInterface in $chooseInterfaceOptions
|
for desiredInterface in $chooseInterfaceOptions
|
||||||
do
|
do
|
||||||
piholeInterface=$desiredInterface
|
piholeInterface=$desiredInterface
|
||||||
echo "::: Using interface: $piholeInterface"
|
echo "::: Using interface: $piholeInterface"
|
||||||
echo ${piholeInterface} > /tmp/piholeINT
|
echo ${piholeInterface} > /tmp/piholeINT
|
||||||
|
|
||||||
# Get interface information
|
# Get interface address information
|
||||||
# Again: While deprecated, ifconfig seems to differentiate between labels better than ip does.
|
|
||||||
IPv4dev=$desiredInterface
|
IPv4dev=$desiredInterface
|
||||||
IPv4addr=$($SUDO ifconfig "$IPv4dev" | grep 'inet addr:' | cut -d: -f2 | cut -d" " -f1)
|
IPv4addresses=$($SUDO ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
|
||||||
IPv4gw=$($SUDO ip route show dev "$IPv4dev" | awk '/default/ {print $3}')
|
IPv4gw=$($SUDO ip route show dev "$IPv4dev" | awk '/default/ {print $3}')
|
||||||
done
|
|
||||||
else
|
# Turn IPv4 addresses into an array so it can be used with a whiptail dialog
|
||||||
|
IPv4Array=()
|
||||||
|
firstloop=1
|
||||||
|
|
||||||
|
while read -r line
|
||||||
|
do
|
||||||
|
mode="OFF"
|
||||||
|
if [[ $firstloop -eq 1 ]]; then
|
||||||
|
firstloop=0
|
||||||
|
mode="ON"
|
||||||
|
IPv4Array+=("$line" "available" "$mode")
|
||||||
|
fi
|
||||||
|
done <<< "$IPv4addresses"
|
||||||
|
|
||||||
|
# Find out how many IP addresses are available to choose from
|
||||||
|
IPv4Count=$(echo "$IPv4addresses" | wc -l)
|
||||||
|
chooseIPv4Cmd=(whiptail --separate-output --radiolist "Choose an IPv4 address on this interface." $r $c $IPv4Count)
|
||||||
|
IPv4addr=$("${chooseIPv4Cmd[@]}" "${IPv4Array[@]}" 2>&1 >/dev/tty)
|
||||||
|
|
||||||
|
if [[ ! ($? = 0) ]];then
|
||||||
echo "::: Cancel selected, exiting...."
|
echo "::: Cancel selected, exiting...."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupIPv6() {
|
cleanupIPv6() {
|
||||||
|
|
Loading…
Reference in a new issue