wok view get-wifi-firmware/stuff/get-wifi-firmware @ rev 24118
Add checker_online
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Oct 04 14:07:53 2021 +0000 (2021-10-04) |
parents | 02c70d036ea0 |
children |
line source
1 #!/bin/sh
2 # install linux-wireless, wireless_tools and b43-fwcutter if needed.
4 MODULE=$(echo $0 | sed 's/.*get-\(.*\)-firmware/\1/')
5 ROOT="$2"
6 PKG=$MODULE-firmware
7 DEPENDS=""
9 MODULE_LIST=""
10 while read module desc ; do
11 [ "$MODULE" = "$module" ] && desc="$SHORT_DESC"
12 MODULE_LIST="$MODULE_LIST $module"
13 done <<EOT
14 b43 Broadcom $MODULE firmware.
15 b43legacy Broadcom $MODULE firmware (BCM4306 rev2 or 802.11b chips).
16 ipw2100 Intel PRO/Wireless 2100 firmware.
17 ipw2200 Intel PRO/Wireless 2200BG firmware.
18 iwlwifi-3945 Intel PRO/Wireless 3945ABG/BG firmware.
19 iwlwifi-4965 Intel WiFi Link 4965AGN firmware.
20 iwlwifi-5000 Intel Wireless WiFi Link 5000AGN firmware.
21 iwlwifi-5150 Intel Wireless WiFi Link 5150AGN firmware.
22 iwlwifi-1000 Intel Wireless WiFi Link 1000BGN firmware.
23 iwlwifi-6000 Intel Wireless WiFi Link 6000 Series Wi-fi Adapters.
24 rt61 new RT2x00 RT61 Wireless Lan firmware.
25 rt61pci new RT2x00 RT61 Wireless Lan firmware.
26 rt73 new RT2x00 RT73(RT2571W) Wireless Lan firmware.
27 rt73usb new RT2x00 RT73(RT2571W) Wireless Lan firmware.
28 rt2870usb RaLink RT2870USB (RT2870/RT2770) WiFi adapter.
29 zd1211 zd1211/zd1211rw Wireless Lan firmware.
30 zd1211rw zd1211/zd1211rw Wireless Lan firmware.
31 EOT
33 case "$MODULE" in
34 b43)
35 WEB_SITE="http://www.linuxwireless.org/en/users/Drivers/b43"
36 WGET_URL="http://mirror2.openwrt.org/sources"
37 VERSION=$(wget -O - $WGET_URL | sed \
38 '/broadcom-wl-[0-9\.]*.tar/!d;s/.*com-wl-\([0-9\.]*\).tar.*/\1/' | \
39 tail -n 1)
40 SUBDIR="broadcom-wl-$VERSION"
41 WGET_URL="$WGET_URL/$SUBDIR.tar.bz2"
42 DEPENDS="b43-fwcutter"
43 FWSET=wl_apsta_mimo.o
44 ;;
45 b43legacy)
46 WEB_SITE="http://downloads.openwrt.org/"
47 VERSION=$(wget -O - ${WEB_SITE}sources | sed \
48 '/wl_apsta/!d;s/.*>wl_apsta-\(.*\).o.*/\1/')
49 WGET_URL="${WEB_SITE}sources/wl_apsta-$VERSION.o"
50 DEPENDS="b43-fwcutter"
51 FWSET=wl_apsta-$VERSION.o
52 ;;
53 ipw2100)
54 VERSION=$(wget -O - http://$MODULE.sourceforge.net/firmware.php?fid=2 |\
55 sed "/$MODULE-fw/!d;s/.*fw-\(.*\).tgz.*/\1/")
56 WEB_SITE="http://$MODULE.sourceforge.net/"
57 WGET_URL="http://bughost.org/firmware/${MODULE}-fw-${VERSION}.tgz"
58 ;;
59 ipw2200)
60 VERSION=$(wget -O - http://$MODULE.sourceforge.net/firmware.php?fid=8 |\
61 sed "/$MODULE-fw/!d;s/.*fw-\(.*\).tgz.*/\1/")
62 WEB_SITE="http://$MODULE.sourceforge.net/"
63 WGET_URL="http://bughost.org/firmware/${MODULE}-fw-${VERSION}.tgz"
64 ;;
65 iwlwifi-*)
66 WEB_SITE="http://www.intellinuxwireless.org/?n=Downloads"
67 VERSION=$(wget -O - $WEB_SITE | sed -e "/$MODULE-/!d" -e \
68 's/.*-ucode-\([0-9\.-]*\).t.*/\1/;q')
69 WGET_URL="http://www.intellinuxwireless.org/iwlwifi/downloads/$MODULE-ucode-$VERSION.tgz"
70 ;;
71 rt61*)
72 WGET_URL="http://archlinux.c3sl.ufpr.br/other/rt2x00-rt61-fw"
73 VERSION=$(wget -O - $WGET_URL | sed '/Firmware/!d;s/.*_V\(.*\).zip.*/\1/')
74 WEB_SITE="http://www.ralinktech.com/"
75 WGET_URL="$WGET_URL/RT61_Firmware_V${VERSION}.zip"
76 ;;
77 rt73*)
78 WGET_URL="http://archlinux.c3sl.ufpr.br/other/rt2x00-rt71w-fw"
79 VERSION=$(wget -O - $WGET_URL | sed '/Firmware/!d;s/.*_V\(.*\).zip.*/\1/')
80 WEB_SITE="http://www.ralinktech.com/"
81 WGET_URL="$WGET_URL/RT71W_Firmware_V${VERSION}.zip"
82 ;;
83 rt2870usb)
84 WGET_URL="http://archlinux.c3sl.ufpr.br/other/${MODULE}-fw"
85 VERSION=$(wget -O - $WGET_URL | sed '/Firmware/!d;s/.*_V\(.*\).zip.*/\1/')
86 WEB_SITE="http://www.ralinktech.com/"
87 WGET_URL="$WGET_URL/RT2870_Firmware_V${VERSION}.zip"
88 ;;
89 zd1211*)
90 WGET_URL="http://mirrors.kernel.org/debian/pool/non-free/z/zd1211-firmware"
91 VERSION=$(wget -O - $WGET_URL | sed -e '/zd1211-firmware/!d' \
92 -e '/all.deb/!d' -e 's/.*>zd1211-firmware_\(.*\)_all.deb.*/\1/')
93 SHORT_DESC="zd1211/zd1211rw Wireless Lan firmware."
94 WEB_SITE="http://packages.debian.org/etch/zd1211-firmware"
95 WGET_URL="$WGET_URL/zd1211-firmware_${VERSION}_all.deb"
96 ;;
97 *)
98 case "$1" in
99 --install)
100 cd $(dirname $0)
101 for i in $MODULE_LIST ; do
102 ln -s get-wifi-firmware get-$i-firmware
103 done
104 exit 0 ;;
105 --get-free-firmware)
106 for i in $MODULE_LIST ; do
107 case "$i" in
108 iwlwifi*|rt*) get-$i-firmware
109 esac
110 done
111 exit 0 ;;
112 esac
113 echo "Unknown wifi driver. Please run one of the following commands:"
114 for i in $(cd $(dirname $0); ls get-*-firmware); do
115 [ -L $i ] || continue
116 [ "$(readlink $i)" = "get-wifi-firmware" ] || continue
117 echo " $i"
118 done
119 exit 1;;
120 esac
122 # Check if user is root to install.
123 if test $(id -u) != 0 ; then
124 echo -e "\nYou must be root to run `basename $0`."
125 echo -e "Please use 'su' and root password to become super-user.\n"
126 exit 0
127 fi
129 # Avoid reinstall
130 if [ -d $ROOT/var/lib/tazpkg/installed/$PKG ]; then
131 echo -e "\n$PKG package is already installed.\n"
132 exit 0
133 fi
135 # We need drivers, the extractor and tools.
136 for pkg in linux-wireless wireless_tools $DEPENDS
137 do
138 if [ ! -d $ROOT/var/lib/tazpkg/installed/$pkg ]; then
139 tazpkg get-install $pkg --root=$ROOT
140 fi
141 done
143 # Get files
144 TMP=/tmp/$(basename $0)$$
145 mkdir $TMP
146 TOP=$PWD
147 cd $TMP
148 wget $WGET_URL
149 TARBALL="$(basename $WGET_URL)"
150 if [ ! -s $TARBALL ]; then
151 cd $TOP
152 rm -rf $DIR
153 echo "Could not download $TARBALL. Exiting."
154 exit 1
155 fi
157 case "$WGET_URL" in
158 *rpm) rpm2cpio < $TARBALL | cpio -id;;
159 *deb) dpkg-deb -x $TARBALL . ;;
160 *bz2) tar xjf $TARBALL
161 cd $SUBDIR/driver;;
162 *tar.gz|*tgz) tar xzf $TARBALL;;
163 *zip) unzip $TARBALL;;
164 *o) ;;
165 *) busybox tar xf $TARBALL;;
166 esac
168 # Create pseudo package
169 mkdir -p $PKG-$VERSION/fs/lib/firmware $PKG-$VERSION/fs/usr/share/licenses
170 case "$MODULE" in
171 b43*) b43-fwcutter -w "$PKG-$VERSION/fs/lib/firmware" $FWSET;;
172 ipw2200) cp ${MODULE}-fw-$VERSION/*LICENSE* $PKG-$VERSION/fs/usr/share/licenses/intel-$MODULE-LICENSE.txt
173 mv ${MODULE}-fw-$VERSION/* $PKG-$VERSION/fs/lib/firmware;;
174 ipw2100) cp *LICENSE* $PKG-$VERSION/fs/usr/share/licenses/intel-$MODULE-LICENSE.txt
175 mv *.fw* *LICENSE* $PKG-$VERSION/fs/lib/firmware;;
176 rt*)
177 mv RT*_Firmware_V$VERSION/*.bin $PKG-$VERSION/fs/lib/firmware
178 mv RT*_Firmware_V$VERSION/*LICENSE* $PKG-$VERSION/fs/usr/share/licenses/ralink-rt61-LICENSE.txt;;
179 iwlwifi*) mv iwlwifi*/iwlwifi*.ucode $PKG-$VERSION/fs/lib/firmware
180 mv iwlwifi*/*LICENSE* $PKG-$VERSION/fs/usr/share/licenses/intel-iwlwifi-LICENSE.txt ;;
181 zd1211*)
182 mv lib/firmware/zd1211 $PKG-$VERSION/fs/lib/firmware
183 for i in $(cd usr/lib/hotplug/firmware; ls); do
184 target=$(readlink usr/lib/hotplug/firmware/$i)
185 ln -s $(basename $target) $PKG-$VERSION/fs/lib/firmware/zd1211/$i
186 done;;
187 esac
189 # Creat receipt
190 cat > $PKG-$VERSION/receipt <<EOT
191 PACKAGE="$PKG"
192 VERSION="$VERSION"
193 CATEGORY="non-free"
194 SHORT_DESC="$SHORT_DESC."
195 WEB_SITE="$WEB_SITE"
196 DEPENDS="linux-wireless wireless_tools $DEPENDS"
197 EOT
199 # Pack
200 tazpkg pack $PKG-$VERSION
202 # Install pseudo package
203 tazpkg install $PKG-$VERSION.tazpkg --root=$ROOT
205 # Clean
206 cd $TOP
207 rm -rf $TMP
209 if [ "$1" = "--firmware" ] ; then
210 echo "just install firmare: yes"
211 JUST_INSTALL_FIRMWARE="yes"
212 fi
214 if [ ! "$JUST_INSTALL_FIRMWARE" = "yes" ]; then
215 echo "configuring and loading module ..."
216 # Check if we need wpa_supplicant
217 . $ROOT/etc/network.conf
218 if [ $WIFI_KEY_TYPE = "wpa" ] || [ $WIFI_KEY_TYPE = "WPA" ]; then
219 if [ ! -d $ROOT/var/lib/tazpkg/installed/wpa_supplicant ]; then
220 tazpkg get-install wpa_supplicant --root=$ROOT
221 fi
222 fi
224 # Configure /etc/network.conf and start connexion
225 sed -i s/'WIFI="no"'/'WIFI="yes"'/ $ROOT/etc/network.conf
227 # Load module
228 if [ -z "$ROOT" -a -n "$(modprobe -l $MODULE)" ]; then
229 echo "Loading module: $MODULE..."
230 if modprobe $MODULE ; then
231 sleep 2
232 /etc/init.d/network.sh restart
233 fi
234 fi
235 fi