From: Nicolas Boisselier Date: Mon, 18 Feb 2019 22:10:27 +0000 (+0000) Subject: etc/profile.d/sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=f00bf0a161f045e876a1c1d05c8e7a2ae418d83f;p=nb.git etc/profile.d/sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index afc6ad5a..9ad12aba 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -19,11 +19,14 @@ sys_infos() { grep -vE "^[^${s}]+${s}$" << EOF arch${s}$(sys_arch) nproc${s}$(sys_nproc) -date_install${s}$(sys_date_install) ips${s}$(echo -n $(ips 2>/dev/null)) -public_ip${s}$( (http_get http://nicolas.boisselier.free.fr/myip/) 2>/dev/null) +interfaces${s}$(echo -n $(sys_interfaces)) model${s}$([ -r /proc/device-tree/model ] && printf '%s\t%s\n' model "$(cat /proc/device-tree/model)") os${s}$(sys_os) +date_install${s}$(sys_date_install) +mem_total${s}$(sys_mem_total) +mem_used${s}$(sys_mem_used) +public_ip${s}$( (http_get http://nicolas.boisselier.free.fr/myip/) 2>/dev/null) EOF } @@ -142,3 +145,15 @@ sys_mem_total() { sys_mem_used() { sysctl -n hw.usermem 2>/dev/null || free -b | awk '/^Mem:/{print $3; exit}' } + +sys_interfaces() { +( + if which ip > /dev/null; then + ip link | awk -F'(: )|@' '/^[^ ]/{print $2}' + + elif which ifconfig > /dev/null; then + ifconfig | awk '/^[^ ]/{print $1}' + + fi +) | awk '!x[$0]++ && $1 !~ /^(lo)$/ {print}' +}