Depending on configuration, disable the LED before writing the trigger
and enable it after writing it. Fixes LEDs where the value defaults to 1
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 45463
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
- [ "$default" != nil ] && {
- [ $default -eq 1 ] &&
- echo 1 >/sys/class/leds/${sysfs}/brightness
- [ $default -eq 1 ] ||
- echo 0 >/sys/class/leds/${sysfs}/brightness
- }
+
+ [ "$default" = 0 ] ||
+ echo 0 >/sys/class/leds/${sysfs}/brightness
+
echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
- [ $? = 0 ] || {
+ ret="$?"
+
+ [ $default = 1 ] &&
+ echo 1 >/sys/class/leds/${sysfs}/brightness
+
+ [ $ret = 0 ] || {
echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module"
return 1
}