diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2016-10-19 12:09:45 +0200 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2016-10-19 12:09:45 +0200 |
commit | 0658527e1ebe666cabde9267b6afbe543314160c (patch) | |
tree | 9afe96f78fd33c15b80786f418ca77a32135b20a /package/base-files/files/etc | |
parent | 1ffb7e47be92e32a08d866399af83d4136e28e06 (diff) | |
download | upstream-0658527e1ebe666cabde9267b6afbe543314160c.tar.gz upstream-0658527e1ebe666cabde9267b6afbe543314160c.tar.bz2 upstream-0658527e1ebe666cabde9267b6afbe543314160c.zip |
switch to the new usbport LED trigger
This makes init.d script handle existing UCI entries using the new
trigger. It also switches all targets to use its package.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/base-files/files/etc')
-rwxr-xr-x | package/base-files/files/etc/init.d/led | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led index 79f2904f7d..9a793e9a95 100755 --- a/package/base-files/files/etc/init.d/led +++ b/package/base-files/files/etc/init.d/led @@ -8,6 +8,7 @@ load_led() { local sysfs local trigger local dev + local ports local mode local default local delayon @@ -34,6 +35,15 @@ load_led() { return fi + [ "$trigger" = "usbdev" ] && { + # Backward compatibility: translate to the new trigger + trigger="usbport" + # Translate port of root hub, e.g. 4-1 -> usb4-port1 + ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p') + # Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4 + [ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p') + } + [ -e /sys/class/leds/${sysfs}/brightness ] && { echo "setting up led ${name}" @@ -71,11 +81,12 @@ load_led() { echo $delayoff > /sys/class/leds/${sysfs}/delay_off ;; - "usbdev") - [ -n "$dev" ] && { - echo $dev > /sys/class/leds/${sysfs}/device_name - echo $interval > /sys/class/leds/${sysfs}/activity_interval - } + "usbport") + local p + + for p in $ports; do + echo 1 > /sys/class/leds/${sysfs}/ports/$p + done ;; "port_state") |