-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBroadcomStartup
More file actions
executable file
·213 lines (164 loc) · 8.46 KB
/
BroadcomStartup
File metadata and controls
executable file
·213 lines (164 loc) · 8.46 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash
#
# It was changed by: kachnu
# email: ya.kachnu@gmail.com
version="BroadcomStartup-1.4 (Jun. 28, 2016) - was changed by kachnu"
show_help () {
echo "$help_text"
exit 0
}
show_version () {
echo "$version"
exit 0
}
help_text="
Usage: `basename $0 | cut -f1 -d_`
The `basename $0 | cut -f1 -d_` script removes the b43, b43legacy and b44 blacklist entries
for Broadcom devices known not to work with the broadcom-sta wl module.
With the exception of the --help and --version options, the `basename $0 | cut -f1 -d_`
script takes no arguments.
valid options:
-h, --help show this help text
-v, --version display the version information
"
while [[ $1 == -* ]]; do
case "$1" in
-h|--help)
show_help ;;
-v|--version)
show_version ;;
*)
echo "invalid option: $1"
echo "Try: $0 -h for full help."
exit 1 ;;
esac
done
# Check that user is root.
if [ $(id -u) -ne 0 ]
then echo "Start $0 with root"
sudo $0 $1
exit 1
fi
b43Unblacklist()
{
if [ -f /etc/modprobe.d/broadcom-sta-dkms.conf ]; then
sed -i 's/blacklist wl$//;s/#blacklist ssb/blacklist ssb/;s/#blacklist b44/blacklist b44/;s/#blacklist b43legacy/blacklist b43legacy/;s/#blacklist bcma/blacklist bcma/;s/#blacklist b43/blacklist b43/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i 's/blacklist b43$/#blacklist b43/;s/blacklist bcma/#blacklist bcma/;s/blacklist ssb/#blacklist ssb/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i -e "\$ablacklist wl" /etc/modprobe.d/broadcom-sta-dkms.conf
[ -x /etc/init.d/network-manager ] && service network-manager stop
modprobe -r wl cfg80211 b44 b43legacy brcmsmac
modprobe b43
[ -x /etc/init.d/network-manager ] && service network-manager start
sleep 2 #(small delay and the networks show up)
pkill wpa_supplicant
fi
}
b43legacyUnblacklist()
{
if [ -f /etc/modprobe.d/broadcom-sta-dkms.conf ]; then
sed -i 's/blacklist wl$//;s/#blacklist ssb/blacklist ssb/;s/#blacklist b44/blacklist b44/;s/#blacklist b43legacy/blacklist b43legacy/;s/#blacklist bcma/blacklist bcma/;s/#blacklist b43/blacklist b43/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i 's/blacklist b43legacy$/#blacklist b43legacy/;s/blacklist ssb/#blacklist ssb/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i -e "\$ablacklist wl" /etc/modprobe.d/broadcom-sta-dkms.conf
[ -x /etc/init.d/network-manager ] && service network-manager stop
modprobe -r wl cfg80211 b44 b43 brcmsmac bcma
modprobe b43legacy
[ -x /etc/init.d/network-manager ] && service network-manager start
sleep 2 #(small delay and the networks show up)
pkill wpa_supplicant
fi
}
b44Unblacklist()
{
if [ -f /etc/modprobe.d/broadcom-sta-dkms.conf ]; then
sed -i 's/blacklist wl$//;s/#blacklist ssb/blacklist ssb/;s/#blacklist b44/blacklist b44/;s/#blacklist b43legacy/blacklist b43legacy/;s/#blacklist bcma/blacklist bcma/;s/#blacklist b43/blacklist b43/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i 's/blacklist b44$/#blacklist b44/;s/blacklist ssb/#blacklist ssb/' /etc/modprobe.d/broadcom-sta-dkms.conf
sed -i -e "\$ablacklist wl" /etc/modprobe.d/broadcom-sta-dkms.conf
[ -x /etc/init.d/network-manager ] && service network-manager stop
modprobe b44
[ -x /etc/init.d/network-manager ] && service network-manager start
sleep 2 #(small delay and the networks show up)
pkill wpa_supplicant
fi
}
wlUnblacklist()
{
if [ -f /etc/modprobe.d/broadcom-sta-dkms.conf ]; then
sed -i 's/blacklist wl$//;s/#blacklist ssb/blacklist ssb/;s/#blacklist b44/blacklist b44/;s/#blacklist b43legacy/blacklist b43legacy/;s/#blacklist bcma/blacklist bcma/;s/#blacklist b43/blacklist b43/' /etc/modprobe.d/broadcom-sta-dkms.conf
[ -x /etc/init.d/network-manager ] && service network-manager stop
modprobe -r b44 b43 b43legacy ssb brcmsmac bcma
modprobe wl cfg80211
[ -x /etc/init.d/network-manager ] && service network-manager start
sleep 2 #(small delay and the networks show up)
pkill wpa_supplicant
fi
}
if [ -e /etc/bcm-ckd ]; then
:
else
DEV_BC=""
# touch /etc/bcm-ckd
#test to see if a broadcom wireless internet device is present
lspci -n | grep -E -q '^[^[:space:]]+\.0[[:space:]]+(0280)+(:)+[[:space:]]+(14e4)'
if [ "$?" -eq 0 ]; then
DEV_BC=$(lspci -n | grep -E '^[^[:space:]]+\.0[[:space:]]+(0280)+(:)+[[:space:]]+(14e4)' | grep -Eio '[a-f0-9]{4}:[a-f0-9]{4}' | grep -Eio [a-f0-9]{4}$ | tr '[A-Z]' '[a-z]')
echo "Find broadcom wireless ID - $DEV_BC"
case $DEV_BC in
4307|4318|4319|4321|4322|4350|43a9|43aa|a8d6|a8db) b43Unblacklist
;;
4311|4312|4328) b43Unblacklist
;;
4301|4306|4325) b43legacyUnblacklist
;;
4320) #test to see if BCM4306/2 or BCM4306/3
#assuming that the first line of the lspci -vnn report for a BCM4306/2 device ends with "(rev 02)", can someone verify?
lspci -vnn -d 14e4:4320 | head -n1 | cut -f2- -d] | cut -c3- | grep -q BCM4306.*"(rev 02)$"
if [ "$?" -eq 0 ]; then
b43legacyUnblacklist
fi
#assuming that the first line of the lspci -vnn report for a BCM4306/3 device ends with "(rev 03)", can someone verify?
lspci -vnn -d 14e4:4320 | head -n1 | cut -f2- -d] | cut -c3- | grep -q BCM4306.*"(rev 03)$"
if [ "$?" -eq 0 ]; then
b43Unblacklist
fi
;;
4324) #test to see if BCM4306 or BCM4306/6
#assuming that the first line of the lspci -vnn report for a BCM4306 device ends with "[14e4:4324]", can someone verify?
lspci -vnn -d 14e4:4324 | head -n1 | cut -f2- -d] | cut -c3- | grep -q BCM4306.*"\[14e4:4324\]$"
if [ "$?" -eq 0 ]; then
b43legacyUnblacklist
fi
#assuming that the first line of the lspci -vnn report for a BCM4306/6 device ends with "(rev 06)", can someone verify?
lspci -vnn -d 14e4:4324 | head -n1 | cut -f2- -d] | cut -c3- | grep -q BCM4306.*"(rev 06)$"
if [ "$?" -eq 0 ]; then
b43Unblacklist
fi
;;
*) #misc type of broadcom device, set default - wl
wlUnblacklist
;;
esac
else
#broadcom wireless device not found, so do nothing
:
fi
#test to see if a broadcom wired internet device is present
lspci -n | grep -E -q '^[^[:space:]]+\.0[[:space:]]+(0200)+(:)+[[:space:]]+(14e4)'
if [ "$?" -eq 0 ]; then
DEV_BC=$(lspci -n | grep -E '^[^[:space:]]+\.0[[:space:]]+(0200)+(:)+[[:space:]]+(14e4)' | grep -Eio '[a-f0-9]{4}:[a-f0-9]{4}' | grep -Eio [a-f0-9]{4}$ | tr '[A-Z]' '[a-z]')
echo "Find broadcom wireless ID - $DEV_BC"
case $DEV_BC in
170c|4401|4402) b44Unblacklist
;;
*) #misc type of broadcom device, set default - wl
wlUnblacklist
;;
esac
else
#broadcom wired internet device not found, so do nothing
:
fi
if [[ $DEV_BC == "" ]]
then echo "There are no changes!"
fi
sleep 2
fi