From c6beb7f5dfdfc222e211ad1b3b9755a4bf1f98d9 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 5 Jan 2022 15:31:13 +0100 Subject: system_usage.sh: check for command dependencies --- system_usage.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/system_usage.sh b/system_usage.sh index d4d3124..e582d4d 100755 --- a/system_usage.sh +++ b/system_usage.sh @@ -1,10 +1,8 @@ #!/bin/bash -# # system_usage.sh # (c) 2022 Jonas Gunz -# License: All rights reserved. -# +# License: MIT # USAGE: # ./system_usage.sh [TTY [BAUD]] @@ -18,6 +16,16 @@ readonly PWM_CPU=0 readonly PWM_RAM=1 readonly PWM_TMP=2 +readonly DEPENDENCIES=( stty nproc sensors ) +for dep in "${DEPENDENCIES[@]}"; do + if ! which "$dep" > /dev/null 2>&1; then + echo "Command '$dep' missing." + FAILED=1 + fi + + test -n "$FAILED" && exit 1 +done + echo "Trying to set $TTY to $BAUD" stty -F "$TTY" "$BAUD" -echo || exit 1 echo OK! -- cgit v1.2.3