rssileds.init 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh /etc/rc.common
  2. # (C) 2012 Daniel Golle, Allnet GmbH <dgolle@allnet.de>
  3. START=96
  4. STOP=96
  5. RSSILEDS_BIN="/usr/sbin/rssileds"
  6. SERVICE_DAEMONIZE=1
  7. SERVICE_WRITE_PID=1
  8. start_rssid() {
  9. local name
  10. local dev
  11. local threshold
  12. local refresh
  13. local leds
  14. config_get name $1 name
  15. config_get dev $1 dev
  16. config_get threshold $1 threshold
  17. config_get refresh $1 refresh
  18. leds="$( cur_iface=$1 ; config_foreach get_led led )"
  19. SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
  20. service_start $RSSILEDS_BIN $dev $refresh $threshold $leds
  21. }
  22. stop_rssid() {
  23. local dev
  24. config_get dev $1 dev
  25. SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
  26. service_stop $RSSILEDS_BIN
  27. }
  28. get_led() {
  29. local name
  30. local sysfs
  31. local trigger
  32. local iface
  33. config_get sysfs $1 sysfs
  34. config_get name $1 name "$sysfs"
  35. config_get trigger $1 trigger "none"
  36. config_get iface $1 iface
  37. config_get minq $1 minq
  38. config_get maxq $1 maxq
  39. config_get offset $1 offset
  40. config_get factor $1 factor
  41. [ "$trigger" = "rssi" ] || return
  42. [ "$iface" = "$cur_iface" ] || return
  43. [ ! "$minq" ] || [ ! "$maxq" ] || [ ! "$offset" ] || [ ! "$factor" ] && return
  44. echo "none" > /sys/class/leds/$sysfs/trigger
  45. echo "$sysfs $minq $maxq $offset $factor"
  46. }
  47. off_led() {
  48. local name
  49. local sysfs
  50. local trigger
  51. config_get sysfs $1 sysfs
  52. config_get name $1 name "$sysfs"
  53. config_get trigger $1 trigger "none"
  54. [ "$trigger" = "rssi" ] || return
  55. echo "0" > /sys/class/leds/$sysfs/brightness
  56. }
  57. start() {
  58. [ -e /sys/class/leds/ ] && [ -x "$RSSILEDS_BIN" ] && {
  59. config_load system
  60. config_foreach start_rssid rssid
  61. }
  62. }
  63. stop() {
  64. config_load system
  65. config_foreach stop_rssid rssid
  66. config_foreach off_led led
  67. }