From 511e8f84d093b6fbb93b044c2ab150e613b88171 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 3 Oct 2024 16:25:36 +0100 Subject: [PATCH] base-files: configure LED when added Currently LED configuration is only carried out once during boot. Apply LED configuration also with a hotplug call when a new LED gets added later. Signed-off-by: Daniel Golle --- package/base-files/files/etc/hotplug.d/leds/00-init | 3 +++ package/base-files/files/etc/init.d/led | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 package/base-files/files/etc/hotplug.d/leds/00-init diff --git a/package/base-files/files/etc/hotplug.d/leds/00-init b/package/base-files/files/etc/hotplug.d/leds/00-init new file mode 100644 index 0000000000..0303e2bc47 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/leds/00-init @@ -0,0 +1,3 @@ +#!/bin/sh + +[ "$ACTION" = "add" ] && /etc/init.d/led start "$DEVICENAME" diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led index ea2688cab2..5130ac7d41 100755 --- a/package/base-files/files/etc/init.d/led +++ b/package/base-files/files/etc/init.d/led @@ -64,6 +64,8 @@ load_led() { config_get gpio $1 gpio "0" config_get_bool inverted $1 inverted "0" + [ "$2" ] && [ "$sysfs" != "$2" ] && return + # execute application led trigger [ -f "/usr/libexec/led-trigger/${trigger}" ] && { . "/usr/libexec/led-trigger/${trigger}" @@ -121,7 +123,7 @@ load_led() { [ -e "/sys/class/leds/${sysfs}/$m" ] && \ echo 1 > /sys/class/leds/${sysfs}/$m done - echo $interval > /sys/class/leds/${sysfs}/interval + echo $interval > /sys/class/leds/${sysfs}/interval 2>/dev/null } ;; @@ -171,6 +173,7 @@ start() { [ -s /var/run/led.state ] && { local led trigger brightness color while read led trigger brightness color; do + [ "$1" ] && [ "$1" != "$led" ] && continue [ -e "/sys/class/leds/$led/trigger" ] && \ echo "$trigger" > "/sys/class/leds/$led/trigger" @@ -185,6 +188,6 @@ start() { } config_load system - config_foreach load_led led + config_foreach load_led led "$1" } }