2
0

04_led_migration 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2013 OpenWrt.org
  4. #
  5. LED_OPTIONS_CHANGED=0
  6. . /lib/functions.sh
  7. do_led_update_sysfs()
  8. {
  9. local cfg=$1; shift
  10. local tuples="$@"
  11. local sysfs
  12. local name
  13. config_get sysfs $cfg sysfs
  14. config_get name $cfg name
  15. [ -z "$sysfs" ] && return
  16. for tuple in $tuples; do
  17. local old=${tuple%=*}
  18. local new=${tuple#*=}
  19. local new_sysfs
  20. new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
  21. [ "$new_sysfs" = "$sysfs" ] && continue
  22. uci set system.${cfg}.sysfs="${new_sysfs}"
  23. LED_OPTIONS_CHANGED=1
  24. logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
  25. done;
  26. }
  27. migrate_leds()
  28. {
  29. config_load system
  30. config_foreach do_led_update_sysfs led "$@"
  31. }
  32. . /lib/ar71xx.sh
  33. board=$(ar71xx_board_name)
  34. case "$board" in
  35. dhp-1565-a1|\
  36. dir-825-c1|\
  37. dir-835-a1)
  38. migrate_leds ":orange:=:amber:" ":wifi_bgn=:wlan2g"
  39. ;;
  40. dr344)
  41. migrate_leds ":red:=:green:" ":yellow:=:green:"
  42. ;;
  43. wndap360)
  44. migrate_leds "wndap360:=netgear:"
  45. ;;
  46. wndr3700)
  47. migrate_leds "wndr3700:=netgear:"
  48. ;;
  49. wndr3700v4 | \
  50. wndr4300)
  51. migrate_leds ":orange:=:amber:"
  52. ;;
  53. wnr2000)
  54. migrate_leds "wnr2000:=netgear:"
  55. ;;
  56. wnr2200)
  57. migrate_leds "wnr2200:=netgear:"
  58. ;;
  59. wnr612-v2)
  60. migrate_leds "wnr612v2:=netgear:"
  61. ;;
  62. wnr1000-v2)
  63. migrate_leds "wnr1000v2:=netgear:"
  64. ;;
  65. *)
  66. ;;
  67. esac
  68. [ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system
  69. exit 0