mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
lan interfaces test done
This commit is contained in:
parent
9f64dfd4ab
commit
f197246e5b
84
inxi
84
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.6.0-b1-t10
|
||||
#### version: 0.6.0-b1-t11
|
||||
#### Date: November 20 2008
|
||||
########################################################################
|
||||
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
|
||||
|
@ -36,6 +36,10 @@
|
|||
#### gawk(gawk), grep(grep), hostname(hostname), lspci(pciutils),
|
||||
#### ps;uptime(procps), runlevel(sysvinit), glxinfo;xdpyinfo;xrandr(xbase-clients)
|
||||
#### Also the proc filesystem should be present and mounted
|
||||
####
|
||||
#### RECOMMENDS (Needed to run certain features)
|
||||
#### One of the following console browsers (for Wan IP test): elinks links links2 lynx w3m
|
||||
#### For local interfaces/IP test: ifconfig (in net-tools for Debian systems)
|
||||
########################################################################
|
||||
#### CONVENTIONS:
|
||||
#### Indentation: TABS
|
||||
|
@ -89,6 +93,7 @@ A_CPU_DATA=''
|
|||
A_GFX_CARD_DATA=''
|
||||
A_GLX_DATA=''
|
||||
A_HDD_DATA=''
|
||||
A_INTERFACES_DATA=''
|
||||
A_NETWORK_DATA=''
|
||||
A_PARTITION_DATA=''
|
||||
A_X_DATA=''
|
||||
|
@ -1811,13 +1816,52 @@ get_networking_wan_ip_data()
|
|||
ip='N/A'
|
||||
fi
|
||||
echo "$ip"
|
||||
|
||||
|
||||
}
|
||||
|
||||
get_networking_local_ip_data()
|
||||
{
|
||||
:
|
||||
|
||||
|
||||
if [[ -n $( which ifconfig ) ]];then
|
||||
IFS=$'\n'
|
||||
A_INTERFACES_DATA=( $( ifconfig | gawk '
|
||||
BEGIN { IGNORECASE=1 }
|
||||
$1 !~ /^lo|^[ \t]/ {
|
||||
# not clear on why inet is coming through, but this gets rid of it
|
||||
# as first line item.
|
||||
if ( $1 != "inet" ) {
|
||||
interface = $1
|
||||
gsub(/,/, " ", interface)
|
||||
gsub(/^ +| +$/, "", interface)
|
||||
gsub(/ [ \t]+/, " ", interface)
|
||||
|
||||
aInterfaces[interface]++
|
||||
while (getline && !/^$/) {
|
||||
if (/inet addr:/) {
|
||||
#ipAddresses[interface] = gensub( /addr:([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})/, "\\1", "g", $2 )
|
||||
ipAddresses[interface] = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
j=0
|
||||
for (i in aInterfaces) {
|
||||
useInterfaceIp = ""
|
||||
a[j]=i
|
||||
if (ipAddresses[i] != "") {
|
||||
useInterfaceIp = ipAddresses[i]
|
||||
}
|
||||
# create array primary item for master array
|
||||
print a[j] "," useInterfaceIp
|
||||
j++
|
||||
}
|
||||
}') )
|
||||
IFS="$ORIGINAL_IFS"
|
||||
else
|
||||
A_INTERFACES_DATA=( "Interfaces requires ifconfig. App missing." )
|
||||
fi
|
||||
}
|
||||
|
||||
get_partition_data()
|
||||
|
@ -2446,7 +2490,7 @@ print_networking_data()
|
|||
fi
|
||||
port_data=" ${C1}at port$port_plural${C2} ${a_network_working[2]}"
|
||||
fi
|
||||
card_string=""
|
||||
card_string=''
|
||||
network_data="${C1}$card_one${C2} ${a_network_working[0]}$driver_data$port_data"
|
||||
network_data=$( create_print_line "Network:" "$network_data" )
|
||||
print_screen_output "$network_data"
|
||||
|
@ -2480,13 +2524,39 @@ print_networking_data()
|
|||
|
||||
print_networking_ip_data()
|
||||
{
|
||||
local ip=$( get_networking_wan_ip_data ) ip_data=''
|
||||
local ip=$( get_networking_wan_ip_data )
|
||||
local ip_data='' a_interfaces_working='' interfaces='' interfaces_2='' i=''
|
||||
|
||||
# set A_INTERFACES_DATA
|
||||
get_networking_local_ip_data
|
||||
# first print output for wan ip line. Null is handled in the get function
|
||||
ip_data=$( create_print_line " " "${C1}Wan IP:${C2} $ip" )
|
||||
print_screen_output "$ip_data"
|
||||
|
||||
# then create the list of local interface/ip
|
||||
interfaces=" ${C1}Interface:${C2}"
|
||||
i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
|
||||
while [[ -n ${A_INTERFACES_DATA[i]} ]]
|
||||
do
|
||||
IFS=","
|
||||
a_interfaces_working=(${A_INTERFACES_DATA[i]})
|
||||
IFS="$ORIGINAL_IFS"
|
||||
if [[ $1 -lt 3 ]];then
|
||||
if [[ -n ${a_interfaces_working[0]} ]];then
|
||||
interfaces="$interfaces ${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]}"
|
||||
fi
|
||||
else
|
||||
if [[ -n ${a_interfaces_working[0]} ]];then
|
||||
interfaces_2="$interfaces_2 ${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]}"
|
||||
fi
|
||||
fi
|
||||
((i++))
|
||||
done
|
||||
print_screen_output "$ip_data$interfaces"
|
||||
# then wrap it if needed
|
||||
if [[ -n $interfaces_2 ]];then
|
||||
interfaces_2=$( create_print_line " " "$interfaces_2" )
|
||||
print_screen_output "$interfaces_2"
|
||||
fi
|
||||
}
|
||||
|
||||
print_system_data()
|
||||
|
|
Loading…
Reference in a new issue