From: Nicolas Boisselier Date: Mon, 20 May 2019 03:00:47 +0000 (+0100) Subject: etc/profile.d/sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a2f98841f395f9fce1601c072079eb6e177c6242;p=nb.git etc/profile.d/sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 8c846b62..8177840f 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -209,7 +209,7 @@ sys_interfaces_all() { fi ) | awk '!x[$0]++ && $1 !~ /^(lo)$/ {print}' | while read int; do - infos=$(( ip addr show "$int" || ifconfig "$int") 2> /dev/null) + infos=$( (ip addr show "$int" || ifconfig "$int") 2> /dev/null ) mac=$(echo "$infos" | awk '/ether ([^ ]+)/{print $2}') [ -z "$mac" ] && continue @@ -235,7 +235,7 @@ sys_cpu_load() { ; } -sys_cpu_temperature() { +sys_temperatures() { # Mac, others # /sys/devices/platform/applesmc.768/temp*input ( @@ -245,3 +245,19 @@ sys_cpu_temperature() { # NB 13.05.19 awk '{printf("%.1f\n",$1/1000)}' /sys/class/thermal/thermal_zone*/temp #awk '{ count++; sum+=$1 } END {printf("%.1f",sum/count/1000)}' /sys/class/thermal/thermal_zone*/temp } + +sys_mount_dir() { + local usage="Usage: sys_mount_dir DIR" + + local dir=${1:?$usage} + [ ! -d "$dir" ] && echo "$usage" && return 1 + local real_dir="$(cd "$dir" && pwd -P)" + [ 0 = 1 \ + -o "$real_dir" = "/" \ + -o "$real_dir" = "$(pwd)" \ + ] && echo "Directory not allowed: $dir ( $real_dir )" && return 1 + + for i in proc dev dev/pts sys; do + echo mount -o bind /$i $dir/$i + done +}