jensp / chaox-ng-livecd

various stuff used to create the chaox-ng livecd

This URL has Read+Write access

chaox-ng-livecd / code / change-drivers.sh
100644 202 lines (201 sloc) 6.058 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
#!/bin/bash
driver_select_menu() {
  dialog --backtitle "Select driver" --title "main menu" --cancel-label "quit" --menu "select your wifi driver" 17 60 10\
  rt73-k2wrlz "rt73 k2wrlz driver (ieee80211)"\
  rt73-rt2x00 "rt73 rt2x00 driver (mac80211)"\
  rt2570-kw2rlz "rt2570 k2wrlz driver (ieee80211)"\
  rt2570-rt2x00 "rt2570 rt2x00 driver (mac80211)"\
  r8187 "r8187 driver (ieee80211)"\
  rtl8187 "rtl8187 driver (mac80211)"\
  madwifi-newhal "madwifi-newhal driver (ieee80211)"\
  ath5k "ath5k driver (mac80211)" 2> /tmp/.driver-select.tmp
  if [ $? != 0 ]
  then
exit; clear
  fi
_selection="$(cat /tmp/.driver-select.tmp)"
  case $_selection in
    rt73-k2wrlz) rt73_k2wrlz;;
    rt73-rt2x00) rt73_rt2x00;;
    rt2570-k2wrlz) rt2570_k2wrlz;;
    rt2570-rt2x00) rt2570_rt2x00;;
    r8187) r8187;;
    rtl8187) rtl8187;;
    madwifi-newhal) madwifi_newhal;;
    ath5k) ath5k;;
  esac
}
down_iface_for_module() {
  module="$1"
  for iface in $(iwconfig 2>&1|grep IEEE|awk '{print $1}')
  do
if ls /sys/class/net/$iface/device/driver/module/drivers/ |grep -q "$module"
    then
sudo ifconfig $iface down
      sleep 3
    fi
done
}
rt73_k2wrlz() {
  if lsmod |grep -q rt2x00lib
  then
dialog --yesno "rt2x00 drivers are loaded, these have to be unloaded before we can load rt73-k2wrlz drivers - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module rt73usb
      sudo rmmod rt2500usb 2>/dev/null
      sudo rmmod rt73usb 2>/dev/null
      sudo rmmod rt2x00usb 2>/dev/null
      sudo rmmod rt2x00lib 2>/dev/null
    else
exit
fi
fi
if $(sudo modprobe rt73)
  then
dialog --msgbox "Successfully loaded rt73-k2wrlz driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
rt73_rt2x00() {
  if lsmod |grep -q "rt73 "
  then
dialog --yesno "rt73-k2wrlz drivers are loaded, these have to be unloaded before we can load rt73-rt2x00 drivers - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module rt73
      sudo rmmod rt73
    else
exit
fi
fi
if sudo modprobe rt73usb
  then
dialog --msgbox "Successfully loaded rt73-rt2x00 driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
rt2570_k2wrlz() {
  if lsmod |grep -q "rt2x00lib"
  then
dialog --yesno "rt2x00 drivers are loaded, these have to be unloaded before we can load rt2570-k2wrlz drivers - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module rt2500usb
      sudo rmmod rt2500usb
      sudo rmmod rt2x00usb 2>/dev/null
      sudo rmmod rt2x00lib 2>/dev/null
    else
exit
fi
fi
if sudo modprobe rt2570
  then
dialog --msgbox "Successfully loaded rt2570-k2wrlz driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
rt2570_rt2x00() {
  if lsmod |grep -q "rt2570 "
  then
dialog --yesno "rt2570-k2wrlz drivers are loaded, these have to be unloaded before we can load rt2570-rt2x00 drivers - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module rt73
      sudo rmmod rt73
    else
exit
fi
fi
if sudo modprobe rt73usb
  then
dialog --msgbox "Successfully loaded rt73-rt2x00 driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
r8187() {
  if lsmod |grep -q rtl8187
  then
dialog --yesno "rtl8187 driver is loaded, it has to be unloaded before we can load r8187 driver - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module rtl8187
      sudo rmmod rtl8187
    else
exit
fi
fi
if sudo modprobe r8187
  then
dialog --msgbox "Successfully loaded r8187 driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
rtl8187() {
  if lsmod |grep -q r8187
  then
dialog --yesno "r8187 driver is loaded, it has to be unloaded before we can load rtl8187 driver - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module r8187
      sudo rmmod r8187
    else
exit
fi
fi
if sudo modprobe rtl8187
  then
dialog --msgbox "Successfully loaded rtl8187 driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
madwifi_newhal() {
  if lsmod |grep -q ath5k
  then
dialog --yesno "ath5k driver is loaded, it has to be unloaded before we can load madwifi-newhal driver - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module ath5k
      sudo rmmod ath5k
    else
exit
fi
fi
  #FIXME very ugly workaround
  if sleep 3 && sudo modprobe ath_pci && sudo madwifi-unload >/dev/null && sudo modprobe ath_pci
  then
dialog --msgbox "Successfully loaded madwifi-newhal driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
ath5k() {
  if lsmod |grep -q ath_pci
  then
dialog --yesno "madwifi driver is loaded, it has to be unloaded before we can load ath5k driver - shall I do this for you?" 0 0
    if [ $? = 0 ]
    then
down_iface_for_module ath_pci
      sudo madwifi-unload >/dev/null 2>&1
    else
exit
fi
fi
if sudo modprobe ath5k
  then
dialog --msgbox "Successfully loaded ath5k driver" 0 0
  else
dialog --msgbox "Something went wrong, make sure you have a device supported by the driver and contact support" 0 0
  fi
}
dialog --msgbox "This script is regarded fairly experimental - it propably won't break anything, but don't be suprised if it fails. If it doesn't work please report the error, thanks." 0 0
while true
do
driver_select_menu
done