summaryrefslogtreecommitdiffstats
path: root/system-config/components/1190-broadcom-sta
blob: 6f27f7f035c80198743b6d2ea49a4c1293b2ecfc (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh

## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


#set -e

Cmdline ()
{
	for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
	do
		case "${_PARAMETER}" in
			live-config.wlan-driver=*|wlan-driver=*)
				LIVE_WLAN_DRIVER="${_PARAMETER#*wlan-driver=}"
				;;
		esac
	done
}

Init ()
{
	# Checking if package is installed
	if [ ! -e /var/lib/dpkg/info/broadcom-sta-common.list ] || \
	   [ -e /var/lib/live/config/broadcom-sta-common ]
	then
		exit 0
	fi

	echo -n " broadcom-sta-common"
}

Config ()
{
	if [ -z "${LIVE_WLAN_DRIVER}" ] && [ -e /usr/bin/lspci ]
	then
		# pci-id of pci class "network controller" subclass "network controller"
		_DEVICE="$(lspci -mn | awk '$2 == "\"0280\"" { gsub ("\"",""); print $3$4 }' | uniq)"

		if [ -n "${_DEVICE}" ]
		then
			if ls /usr/share/live/config/broadcom-sta/*.ids > /dev/null 2>&1
			then
				# wlan-driver manual overrides
				for _OVERRIDE_IDS in /usr/share/live/config/broadcom-sta/*.ids
				do
					if [ -e "${_OVERRIDE_IDS}" ]
					then
						if grep -qs "${_DEVICE}" "${_OVERRIDE_IDS}"
						then
							LIVE_WLAN_DRIVER="$(basename ${_OVERRIDE_IDS} .ids)"

							break
						fi
					fi
				done
			fi

			if [ -z "${LIVE_WLAN_DRIVER}" ]
			then
				# wlan-driver automatic override for broadcom-sta
				if echo "${_DEVICE}" | grep -qs '^14e4'
				then
					if grep -qs "${_DEVICE}" /usr/share/broadcom-sta/broadcom-sta.ids
					then
						LIVE_WLAN_DRIVER="broadcom-sta"
					fi
				fi
			fi
		fi
	fi

	if [ -n "${LIVE_WLAN_DRIVER}" ]
	then
		mkdir -p /etc/modprobe.d

		if [ -e "/usr/share/live/config/broadcom-sta/${LIVE_WLAN_DRIVER}.conf" ]
		then
			# wlan-driver manual override
			cp "/usr/share/live/config/broadcom-sta/${LIVE_WLAN_DRIVER}.conf" /etc/modprobe.d/broadcom-sta-dkms.conf
		else
			# wlan-driver automatic override
			if [ -e /etc/modprobe.d/broadcom-sta-dkms.conf ]
			then
				case "${LIVE_WLAN_DRIVER}" in
					broadcom-sta)
						sed -i -e 's|^ *blacklist|# blacklist|' /etc/modprobe.d/broadcom-sta-dkms.conf

						if ! grep -qs "^blacklist wl" /etc/modprobe.d/broadcom-sta-dkms.conf
						then
							echo "blacklist wl" >> /etc/modprobe.d/broadcom-sta-dkms.conf
						fi
						;;

					*)
						sed -i -e 's|^# *blacklist|blacklist|g' /etc/modprobe.d/broadcom-sta-dkms.conf
						sed -i -e 's|^blacklist wl|#blacklist wl|g' /etc/modprobe.d/broadcom-sta-dkms.conf
						;;
				esac
			fi
		fi

		# Creating state file
		touch /var/lib/live/config/broadcom-sta
	fi
}

Cmdline
Init
Config