ar71xx: use netgear prefix for WNDAP360 LED names
[openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / 04_led_migration
1 #!/bin/sh
2 #
3 # Copyright (C) 2013 OpenWrt.org
4 #
5
6 LED_OPTIONS_CHANGED=0
7
8 . /lib/functions.sh
9
10 do_led_update_sysfs()
11 {
12         local cfg=$1; shift
13         local tuples="$@"
14         local sysfs
15         local name
16
17         config_get sysfs $cfg sysfs
18         config_get name $cfg name
19
20         [ -z "$sysfs" ] && return
21
22         for tuple in $tuples; do
23                 local old=${tuple%=*}
24                 local new=${tuple#*=}
25                 local new_sysfs
26
27                 new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
28
29                 [ "${new_sysfs}" == "${sysfs}" ] && continue
30
31                 uci set system.${cfg}.sysfs="${new_sysfs}"
32                 LED_OPTIONS_CHANGED=1
33
34                 logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
35         done;
36 }
37
38 migrate_leds()
39 {
40         config_load system
41         config_foreach do_led_update_sysfs led "$@"
42 }
43
44 . /lib/ar71xx.sh
45
46 board=$(ar71xx_board_name)
47
48 case "$board" in
49 wndap360)
50         migrate_leds "wndap360:=netgear:"
51         ;;
52
53 wndr3700)
54         migrate_leds "wndr3700:=netgear:"
55         ;;
56
57 wnr2000)
58         migrate_leds "wnr2000:=netgear:"
59         ;;
60
61 wnr2200)
62         migrate_leds "wnr2200:=netgear:"
63         ;;
64
65 wnr612-v2)
66         migrate_leds "wnr612v2:=netgear:"
67         ;;
68
69 *)
70         ;;
71 esac
72
73 [ "$LED_OPTIONS_CHANGED" == "1" ] && uci commit system
74
75 exit 0