]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/sys.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 18 Feb 2019 22:10:27 +0000 (22:10 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 18 Feb 2019 22:10:27 +0000 (22:10 +0000)
etc/profile.d/sys.sh

index afc6ad5a16d19c0b068daba450f7e731d9535a06..9ad12aba2e61cea74780c2fa90818406a4c25978 100644 (file)
@@ -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}'
+}