mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Sanity check fan control values
This commit is contained in:
parent
afd52609a2
commit
3be9d4cef3
24
raspi-config
24
raspi-config
@ -1207,6 +1207,18 @@ do_fan() {
|
|||||||
GPIO=$2
|
GPIO=$2
|
||||||
fi
|
fi
|
||||||
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
|
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)
|
TIN=$(whiptail --inputbox "At what temperature in degrees should the fan turn on?" 20 60 "$TNOW" 3>&1 1>&2 2>&3)
|
||||||
else
|
else
|
||||||
@ -1216,6 +1228,18 @@ do_fan() {
|
|||||||
TIN=$3
|
TIN=$3
|
||||||
fi
|
fi
|
||||||
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 ))
|
TEMP=$(( $TIN * 1000 ))
|
||||||
fi
|
fi
|
||||||
if [ $RET -eq 0 ]; then
|
if [ $RET -eq 0 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user