mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-19 19:30:16 +00:00
Update to chooseInterface function
This commit is contained in:
parent
4516137dca
commit
b2362ab591
1 changed files with 18 additions and 13 deletions
|
@ -222,27 +222,32 @@ verifyFreeDiskSpace() {
|
||||||
|
|
||||||
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
|
||||||
interfacesArray=()
|
local interfacesArray=()
|
||||||
firstloop=1
|
# Number of available interfaces
|
||||||
|
local interfaceCount
|
||||||
|
# Whiptail variable storage
|
||||||
|
local chooseInterfaceCmd
|
||||||
|
# Temporary Whiptail options storage
|
||||||
|
local chooseInterfaceOptions
|
||||||
|
# Loop sentinel variable
|
||||||
|
local firstLoop=1
|
||||||
|
|
||||||
while read -r line
|
while read -r line; do
|
||||||
do
|
|
||||||
mode="OFF"
|
mode="OFF"
|
||||||
if [[ $firstloop -eq 1 ]]; then
|
if [[ ${firstloop} -eq 1 ]]; then
|
||||||
firstloop=0
|
firstloop=0
|
||||||
mode="ON"
|
mode="ON"
|
||||||
fi
|
fi
|
||||||
interfacesArray+=("$line" "available" "$mode")
|
interfacesArray+=("${line}" "available" "${mode}")
|
||||||
done <<< "$availableInterfaces"
|
done <<< "$availableInterfaces"
|
||||||
|
|
||||||
# Find out how many interfaces are available to choose from
|
# Find out how many interfaces are available to choose from
|
||||||
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 (press space to select)" $r $c ${interfaceCount})
|
||||||
if chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
|
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
|
||||||
then
|
if [[ $? = 0 ]]; then
|
||||||
for desiredInterface in $chooseInterfaceOptions
|
for desiredInterface in ${chooseInterfaceOptions}; do
|
||||||
do
|
pivpnInterface=${desiredInterface}
|
||||||
pivpnInterface=$desiredInterface
|
|
||||||
echo "::: Using interface: $pivpnInterface"
|
echo "::: Using interface: $pivpnInterface"
|
||||||
echo "${pivpnInterface}" > /tmp/pivpnINT
|
echo "${pivpnInterface}" > /tmp/pivpnINT
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue