base-files: fix led script to skip missing triggers
authorJohn Crispin <john@openwrt.org>
Fri, 23 Jan 2015 12:33:04 +0000 (12:33 +0000)
committerJohn Crispin <john@openwrt.org>
Fri, 23 Jan 2015 12:33:04 +0000 (12:33 +0000)
this is based on http://patchwork.ozlabs.org/patch/424451/

Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 44087

package/base-files/files/etc/init.d/led

index d2310f019df67bc45f161a4bf44c683cc854c355..6962bfa84393a2a51488adb36a15b9199f86bd93 100755 (executable)
@@ -40,7 +40,11 @@ load_led() {
                        [ $default -eq 1 ] ||
                                echo 0 >/sys/class/leds/${sysfs}/brightness
                }
-               echo $trigger > /sys/class/leds/${sysfs}/trigger
+               echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
+               [ $? = 0 ] || {
+                       echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module"
+                       return 1
+               }
                case "$trigger" in
                "netdev")
                        [ -n "$dev" ] && {