04_led_migration 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. wndap360)
  41. migrate_leds "wndap360:=netgear:"
  42. ;;
  43. wndr3700)
  44. migrate_leds "wndr3700:=netgear:"
  45. ;;
  46. wndr3700v4 | \
  47. wndr4300)
  48. migrate_leds ":orange:=:amber:"
  49. ;;
  50. wnr2000)
  51. migrate_leds "wnr2000:=netgear:"
  52. ;;
  53. wnr2200)
  54. migrate_leds "wnr2200:=netgear:"
  55. ;;
  56. wnr612-v2)
  57. migrate_leds "wnr612v2:=netgear:"
  58. ;;
  59. wnr1000-v2)
  60. migrate_leds "wnr1000v2:=netgear:"
  61. ;;
  62. *)
  63. ;;
  64. esac
  65. [ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system
  66. exit 0