mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-24 23:23:42 +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,23 +147,48 @@ 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
|
||||||
for desiredInterface in $chooseInterfaceOptions
|
echo "::: Cancel selected, exiting...."
|
||||||
do
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for desiredInterface in $chooseInterfaceOptions
|
||||||
|
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
|
||||||
echo "::: Cancel selected, exiting...."
|
IPv4Array=()
|
||||||
exit 1
|
firstloop=1
|
||||||
fi
|
|
||||||
|
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...."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue