[openwrt/openwrt] base-files: fix shell scope error for the default LED brightness

LEDE Commits lede-commits at lists.infradead.org
Sat Dec 14 10:52:21 PST 2024


blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/3c7134fa320b823ab7c5f91dd1ad948491d97478

commit 3c7134fa320b823ab7c5f91dd1ad948491d97478
Author: Andre Heider <a.heider at gmail.com>
AuthorDate: Sat Dec 14 11:27:09 2024 +0100

    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 at gmail.com>
    Link: https://github.com/openwrt/openwrt/issues/17269
    Signed-off-by: John Crispin <john at phrozen.org>
---
 package/base-files/files/etc/init.d/led | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index d292e2a8dd..79fdd452ce 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -106,9 +106,10 @@ load_led() {
 		[ "$default" = 0 ] &&
 			echo 0 >/sys/class/leds/${sysfs}/brightness
 
-		[ $default = 1 ] &&
-			[ -z "$brightness" ] && brightness=$(cat /sys/class/leds/${sysfs}/max_brightness)
-			echo $brightness > /sys/class/leds/${sysfs}/brightness
+		[ "$default" = 1 ] && {
+			[ -z "$brightness" ] && brightness="$(cat /sys/class/leds/${sysfs}/max_brightness)"
+			echo "$brightness" > /sys/class/leds/${sysfs}/brightness
+		}
 
 		led_color_set "$1" "$sysfs"
 




More information about the lede-commits mailing list