From 54f087651ab461e528aed180733a3cb9197499c0 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 1 Sep 2010 10:59:46 -0600 Subject: [PATCH] * lib/byobu/ip_address, share/man/man1/byobu.1: - display both ifconfig and ip output in ip_address detail display - use ip rather than ifconfig to get the ip address, slight performance improvement - support a flag, IPV6=1, in .byobu/status, to allow for showing IPv6 addresses instead of IPv4 - thanks to Mark Schouten for the IPv6 idea and sample code --- debian/changelog | 8 ++++++++ usr/lib/byobu/ip_address | 26 +++++++++++++++++++++----- usr/share/man/man1/byobu.1 | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7f866126..c8437b6b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,14 @@ byobu (3.4) unreleased; urgency=low gnome-terminal * bin/byobu-janitor, share/byobu/keybindings/f-keys: use sed -e, for Mac OS X compatibility, LP: #625387 + * lib/byobu/ip_address, share/man/man1/byobu.1: + - display both ifconfig and ip output in ip_address detail display + - use ip rather than ifconfig to get the ip address, slight performance + improvement + - support a flag, IPV6=1, in .byobu/status, to allow for showing + IPv6 addresses instead of IPv4 + - thanks to Mark Schouten for the IPv6 idea and + sample code -- Dustin Kirkland Tue, 24 Aug 2010 18:21:14 -0400 diff --git a/usr/lib/byobu/ip_address b/usr/lib/byobu/ip_address index 6c021f12..8e0655af 100755 --- a/usr/lib/byobu/ip_address +++ b/usr/lib/byobu/ip_address @@ -21,7 +21,9 @@ PKG="byobu" color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then - /sbin/ifconfig + [ -x /sbin/ifconfig ] && /sbin/ifconfig + /sbin/ip -4 addr list + /sbin/ip -6 addr list exit 0 fi @@ -33,11 +35,25 @@ fi if [ -n "$MONITORED_NETWORK" ]; then interface="$MONITORED_NETWORK" else - interface=`tail -n1 /proc/net/route | awk '{print $1}'` + case "$IPV6" in + 1|true|yes) interface=$(grep -v "\Wlo$" /proc/net/ipv6_route | tail -n1 | awk '{print $10}') ;; + *) interface=$(tail -n1 /proc/net/route | awk '{print $1}') ;; + esac fi -ipaddr=$(LC_ALL=C /sbin/ifconfig "$interface") -ipaddr=${ipaddr#* inet addr:} -ipaddr=${ipaddr%% *} +case "$IPV6" in + 1|true|yes) + ipaddr=$(LC_ALL=C /sbin/ip -6 addr list dev "$interface") + # Print 'None' if we have no global address + [ -z "$ipaddr" ] && ipaddr="None" + ipaddr=${ipaddr#* inet6 } + ipaddr=${ipaddr%%/*} + ;; + *) + ipaddr=$(LC_ALL=C /sbin/ip -4 addr list dev "$interface") + ipaddr=${ipaddr#* inet } + ipaddr=${ipaddr%%/*} + ;; +esac printf "%s$(color bold2)%s$(color -)" "$space" "$ipaddr" diff --git a/usr/share/man/man1/byobu.1 b/usr/share/man/man1/byobu.1 index af42203e..70597dea 100644 --- a/usr/share/man/man1/byobu.1 +++ b/usr/share/man/man1/byobu.1 @@ -42,7 +42,7 @@ byobu \- wrapper script for seeding a user's byobu configuration and launching s \fBhostname\fP \- the hostname of the system; displayed in the upper bar on the far right in bold black text on a grey background; there is a leading '@' symbol if the username status is also enabled -\fBip_address\fP \- the ip address of the system in dotted decimal form; displayed in the upper bar on the far right in bold black text on a grey background +\fBip_address\fP \- the IPv4 address of the system in dotted decimal form; displayed in the upper bar on the far right in bold black text on a grey background; you can override and display your IPv6 address by setting 'IPV6=1' in \fI$HOME/.byobu/statusrc\fP \fBload_average\fP \- the system load average over the last 1 minute; displayed in the lower bar toward the right in black text on a yellow background