]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/sys.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 20 May 2019 03:00:47 +0000 (04:00 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 20 May 2019 03:00:47 +0000 (04:00 +0100)
etc/profile.d/sys.sh

index 8c846b62999732fb7a32305c7e74c3ad7666761f..8177840f49704d93eb0ccdafe9f07811dd4b66e4 100644 (file)
@@ -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
+}