base-files: fix shell scope error for the default LED brightness

This fixes "sh: write error: Invalid argument" for all default!=1 LEDs
as an empty $brightness was used.

Setting up LEDs via luci also now works again.

Fixes cbdfd03e: "base-files: add option to set LED brightness"
Signed-off-by: Andre Heider <a.heider@gmail.com>
Link: https://github.com/openwrt/openwrt/issues/17269
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
Andre Heider 2024-12-14 11:27:09 +01:00 committed by John Crispin
parent 15e173bf7e
commit 3c7134fa32

View File

@ -106,9 +106,10 @@ load_led() {
[ "$default" = 0 ] && [ "$default" = 0 ] &&
echo 0 >/sys/class/leds/${sysfs}/brightness echo 0 >/sys/class/leds/${sysfs}/brightness
[ $default = 1 ] && [ "$default" = 1 ] && {
[ -z "$brightness" ] && brightness=$(cat /sys/class/leds/${sysfs}/max_brightness) [ -z "$brightness" ] && brightness="$(cat /sys/class/leds/${sysfs}/max_brightness)"
echo $brightness > /sys/class/leds/${sysfs}/brightness echo "$brightness" > /sys/class/leds/${sysfs}/brightness
}
led_color_set "$1" "$sysfs" led_color_set "$1" "$sysfs"