-
Notifications
You must be signed in to change notification settings - Fork 0
/
vnet-tui.subr
99 lines (81 loc) · 1.79 KB
/
vnet-tui.subr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
if [ ! "$_CBSD_VNET_TUI_SUBR" ]; then
_CBSD_VNET_TUI_SUBR=1
###
# form for $interface
select_local_interface()
{
local _input _def_iface _mynic _mydesc _mystatus
local defaultitem=
f_dialog_default_fetch defaultitem
local title=" interface "
local prompt="${interface_msg}"
hline=
local menu_list="
'EXIT' 'EXIT' 'Exit'
" # END-QUOTE
menu_list="${menu_list} 'auto' 'auto' 'Use node uplink interface'"
menu_list="${menu_list} '-' '-' ''"
local OLDIFS="${IFS}"
local IFS=":"
local _num=1
eval $( ${miscdir}/nics-list -d -s "lo" |while read _nicname _nicdesc _nicstatus; do
echo "nic${_num}_name=\"${_nicname}\""
echo "nic${_num}_desc=\"${_nicdesc}\""
echo "nic${_num}_status=\"${_nicstatus}\""
_num=$(( _num + 1 ))
done )
IFS="${OLDIFS}"
if [ -n "${interface}" ]; then
case "${interface}" in
"0")
defaultitem="disable"
;;
*)
defaultitem="${interface}"
esac
else
defaultitem="auto"
fi
for _num in $( /usr/bin/seq 1 9999 ); do
unset _mynic _mydesc _mystatus
eval _mynic="\$nic${_num}_name"
[ -z "${_mynic}" ] && break
eval _mydesc="\$nic${_num}_desc"
eval _mystatus="\$nic${_num}_status"
case "${_mynic%%[0-9]*}" in
tun|bridge|epair|tap|vlan)
_mydesc="Pseudo interface"
;;
lo)
_mydesc="Loopback interface"
;;
esac
[ -z "${_mydesc}" ] && _mydesc="Not available"
menu_list="${menu_list} '${_mynic}' '${_mynic} (${_mystatus} )' 'Description: ${_mydesc}'"
done
cbsd_menubox
retval=$?
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
f_dialog_default_store "$menu_choice"
case $retval in
0)
case "${mtag}" in
"-"|"EXIT")
return 1
;;
"disable")
interface="0"
;;
*)
interface="${mtag}"
;;
esac
;;
*)
;;
esac
return ${retval}
}
###
fi