diff options
author | Jonathan Bauer | 2019-06-17 18:23:13 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-06-17 18:24:15 +0200 |
commit | 5d51e7a3d9789fa82a770ebef10c52e0a7537647 (patch) | |
tree | f69c6c6d9b554232b83ba0cd7361cd06c7b55f54 /core/modules/hardware-stats | |
parent | [vbox-src] Bump to 6.0.8 (diff) | |
download | mltk-5d51e7a3d9789fa82a770ebef10c52e0a7537647.tar.gz mltk-5d51e7a3d9789fa82a770ebef10c52e0a7537647.tar.xz mltk-5d51e7a3d9789fa82a770ebef10c52e0a7537647.zip |
[hardware-stats] use slx-tools for ID44
Diffstat (limited to 'core/modules/hardware-stats')
-rwxr-xr-x | core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats index 423bbe64..8f2ea848 100755 --- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats +++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats @@ -8,6 +8,8 @@ export LANG=C export LC_ALL=C +export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin + touch "/tmp/hw-delete-list" || exit 10 chmod 0600 "/tmp/hw-delete-list" || exit 11 echo -n "" > "/tmp/hw-delete-list" || exit 12 @@ -153,21 +155,29 @@ echo "$VIRTTYPE is $VT" # 8) ID44 partition size ID44=0 -# Try df first, make sure device starts with /dev -read -r df_dev df_size df_used df_avail df_usepercent df_mountpoint df_crap < <(df -P /tmp | grep ' /tmp$') -if [ -n "${df_size}" ] && [ "${df_dev:0:5}" = "/dev/" ]; then - # df reports kbytes, convert to MB - ID44=$(( df_size / 1024 )) -fi -if [ "$ID44" = 0 ]; then - # slxfdisk fallback - for c in $(slxfdisk -l | grep -E '[0-9]+[\-\+]?\s+44\s+' | awk '{print $1}'); do - val=$(blockdev --getsize64 "$c") - [ -z "$val" ] && continue - [ "$val" -gt "$ID44" ] && ID44=$val - done - # blockdev reports bytes, convert to MB - ID44=$(( $ID44 / 1058576 )) # we'd rather underreport +if ! slx-tools fs_path_isvolatile "/tmp" ; then + ID44_SPACE=($(slx-tools fs_path_space "/tmp")) + [ -n "${ID44_SPACE[1]}" ] && ID44="$(( ${ID44_SPACE[1]} / 1024 ))" + + if [ "$ID44" -ne 0 ]; then + # Fallback to old way to detect it + # Try df first, make sure device starts with /dev + read -r df_dev df_size df_used df_avail df_usepercent df_mountpoint df_crap < <(df -P /tmp | grep ' /tmp$') + if [ -n "${df_size}" ] && [ "${df_dev:0:5}" = "/dev/" ]; then + # df reports kbytes, convert to MB + ID44=$(( df_size / 1024 )) + fi + if [ "$ID44" = 0 ]; then + # slxfdisk fallback + for c in $(slxfdisk -l | grep -E '[0-9]+[\-\+]?\s+44\s+' | awk '{print $1}'); do + val=$(blockdev --getsize64 "$c") + [ -z "$val" ] && continue + [ "$val" -gt "$ID44" ] && ID44=$val + done + # blockdev reports bytes, convert to MB + ID44=$(( $ID44 / 1058576 )) # we'd rather underreport + fi + fi fi echo "Temp partition: $ID44 MB" |