aboutsummaryrefslogtreecommitdiff
path: root/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
blob: 6504dc81a58c53e2e1054f8e50645061eadf60c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh

# This must run before 10-wifi-detect


[ "${ACTION}" = "add" ] || return


. /lib/functions.sh


check_radio()
{
	local cfg="$1" to="$2"

	config_get path "$cfg" path

	[ "$path" = "$to" ] && PATH_EXISTS=true
}

do_migrate_radio()
{
	local cfg="$1" from="$2" to="$3"

	config_get path "$cfg" path

	[ "$path" = "$from" ] || return

	uci set "wireless.${cfg}.path=${to}"
	WIRELESS_CHANGED=true

	logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'"
}

migrate_radio()
{
	local from="$1" to="$2"

	config_load wireless

	# Check if there is already a section with the target path: In this case, the system
	# was already upgraded to a version without this migration script before; better bail out,
	# as we can't be sure we don't break more than we fix.
	PATH_EXISTS=false
	config_foreach check_radio wifi-device "$to"
	$PATH_EXISTS && return

	config_foreach do_migrate_radio wifi-device "$from" "$to"
}


WIRELESS_CHANGED=false

case "$(board_name)" in
arcadyan,we420223-99|\
beeline,smartbox-flash|\
mts,wg430223)
	migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
	migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0+1' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0+1'
	;;
netgear,r6220|\
netgear,wac104|\
netgear,wndr3700-v5)
	migrate_radio '1e140000.pcie/pci0000:00/0000:00:01.0/0000:02:00.0' '1e140000.pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
	;;
zbtlink,zbt-we1326)
	migrate_radio '1e140000.pcie/pci0000:00/0000:00:01.0/0000:02:00.0' '1e140000.pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
	migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
	;;

esac

$WIRELESS_CHANGED && uci commit wireless

exit 0