Do not allow LED operation to be changed unless it is already in a valid state

This commit is contained in:
Simon Long 2020-09-03 16:38:34 +01:00
parent 05561e206b
commit 2125ae6d18

View File

@ -1120,14 +1120,23 @@ do_pi4video() {
get_leds () { get_leds () {
if grep -q "\\[actpwr\\]" /sys/class/leds/led0/trigger ; then if grep -q "\\[actpwr\\]" /sys/class/leds/led0/trigger ; then
echo 0 echo 0
else elif grep -q "\\[default-on\\]" /sys/class/leds/led0/trigger ; then
echo 1 echo 1
else
echo -1
fi fi
} }
do_leds() { do_leds() {
CURRENT=$(get_leds)
if [ $CURRENT -eq -1 ] ; then
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The LED behaviour cannot be changed on this model of Raspberry Pi" 20 60 1
fi
return 1
fi
DEFAULT=--defaultno DEFAULT=--defaultno
if [ $(get_leds) -eq 0 ]; then if [ $CURRENT -eq 0 ]; then
DEFAULT= DEFAULT=
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then