From 3be9d4cef3fb8a986b8f8c6c2cf149c21822f319 Mon Sep 17 00:00:00 2001 From: Simon Long Date: Tue, 6 Oct 2020 15:11:23 +0100 Subject: [PATCH] Sanity check fan control values --- raspi-config | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/raspi-config b/raspi-config index 3efe12d..581b0f2 100755 --- a/raspi-config +++ b/raspi-config @@ -1207,6 +1207,18 @@ do_fan() { GPIO=$2 fi fi + if ! echo "$GPIO" | grep -q ^[[:digit:]]*$ ; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "GPIO must be a number between 2 and 27" 20 60 1 + fi + return 1 + fi + if [ "$GPIO" -lt 2 ] || [ "$GPIO" -gt 27 ] ; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "GPIO must be a number between 2 and 27" 20 60 1 + fi + return 1 + fi if [ "$INTERACTIVE" = True ]; then TIN=$(whiptail --inputbox "At what temperature in degrees should the fan turn on?" 20 60 "$TNOW" 3>&1 1>&2 2>&3) else @@ -1216,6 +1228,18 @@ do_fan() { TIN=$3 fi fi + if ! echo "$TIN" | grep -q ^[[:digit:]]*$ ; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "Temperature must be a number between 60 and 120" 20 60 1 + fi + return 1 + fi + if [ "$TIN" -lt 60 ] || [ "$TIN" -gt 120 ] ; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "Temperature must be a number between 60 and 120" 20 60 1 + fi + return 1 + fi TEMP=$(( $TIN * 1000 )) fi if [ $RET -eq 0 ]; then