mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 22:34:23 -07:00
- add a get_network_interface function
* usr/lib/byobu/ip_address, usr/lib/byobu/network, usr/lib/byobu/.shutil: - reuse the get_network_interface function across network operations
This commit is contained in:
parent
995ccc9b76
commit
88a342a56f
4 changed files with 17 additions and 21 deletions
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -11,9 +11,12 @@ byobu (4.23) unreleased; urgency=low
|
||||||
* usr/lib/byobu/logo:
|
* usr/lib/byobu/logo:
|
||||||
- revert whitespace required by statusd
|
- revert whitespace required by statusd
|
||||||
* usr/lib/byobu/ip_address, usr/lib/byobu/.shutil:
|
* usr/lib/byobu/ip_address, usr/lib/byobu/.shutil:
|
||||||
- add a get_default_interface function
|
- add a get_network_interface function
|
||||||
- something seems to have changed around the linux 3.0 kernel,
|
- something seems to have changed around the linux 3.0 kernel,
|
||||||
in the order of /proc/net/dev; now test for 0.0.0.0 mask
|
in the order of /proc/net/dev; now test for 0.0.0.0 mask
|
||||||
|
* usr/lib/byobu/ip_address, usr/lib/byobu/network,
|
||||||
|
usr/lib/byobu/.shutil:
|
||||||
|
- reuse the get_network_interface function across network operations
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 24 Jul 2011 14:23:38 -0500
|
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 24 Jul 2011 14:23:38 -0500
|
||||||
|
|
||||||
|
|
|
@ -270,12 +270,16 @@ get_now() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_default_interface() {
|
get_network_interface() {
|
||||||
|
if [ -n "$MONITORED_NETWORK" ]; then
|
||||||
|
_RET="$MONITORED_NETWORK"
|
||||||
|
else
|
||||||
local Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
|
local Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
|
||||||
while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do
|
while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do
|
||||||
[ "$Mask" = "00000000" ] && break
|
[ "$Mask" = "00000000" ] && break
|
||||||
done < /proc/net/route
|
done < /proc/net/route
|
||||||
_RET="$Iface"
|
_RET="$Iface"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
# vi: syntax=sh ts=4 noexpandtab
|
||||||
|
|
|
@ -33,7 +33,7 @@ __ip_address() {
|
||||||
else
|
else
|
||||||
case "$IPV6" in
|
case "$IPV6" in
|
||||||
1|true|yes) interface=$(awk '$10 != "lo" { iface=$10 ; }; END { print iface; }' /proc/net/ipv6_route);;
|
1|true|yes) interface=$(awk '$10 != "lo" { iface=$10 ; }; END { print iface; }' /proc/net/ipv6_route);;
|
||||||
*) get_default_interface; interface="$_RET";;
|
*) get_network_interface; interface="$_RET";;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
case "$IPV6" in
|
case "$IPV6" in
|
||||||
|
|
|
@ -19,24 +19,13 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
get_interface() {
|
|
||||||
_RET=
|
|
||||||
# Allow interface overrides in $BYOBU_CONFIG_DIR/status
|
|
||||||
if [ -n "$MONITORED_NETWORK" ]; then
|
|
||||||
_RET="$MONITORED_NETWORK"
|
|
||||||
else
|
|
||||||
# get the last interface listed in /proc/net/route
|
|
||||||
while read cn other; do _RET=$cn; done < /proc/net/route
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
__network_detail() {
|
__network_detail() {
|
||||||
get_interface; local interface="$_RET"
|
get_network_interface; local interface="$_RET"
|
||||||
LC_ALL=C /sbin/ifconfig "$interface" | $SED 's/\s*$//'
|
LC_ALL=C /sbin/ifconfig "$interface" | $SED 's/\s*$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
__network() {
|
__network() {
|
||||||
get_interface; local interface="$_RET"
|
get_network_interface; local interface="$_RET"
|
||||||
local t1=0 t2=0 x1=0 x2=0
|
local t1=0 t2=0 x1=0 x2=0
|
||||||
# By default, we won't bug the user with the display of network traffic
|
# By default, we won't bug the user with the display of network traffic
|
||||||
# below NETWORK_THRESHOLD in kbps; override in $BYOBU_CONFIG_DIR/status
|
# below NETWORK_THRESHOLD in kbps; override in $BYOBU_CONFIG_DIR/status
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue