# hook addon for wireless # need wireless-tools (firmware....) if [ ! $TCOS_WIRELESS ]; then _verbose "(03wireless) TCOS_WIRELESS disabled" else stat_before # copy wireless utils (some aren't necesary) cpifexists /sbin/iwconfig /sbin/ cpifexists /sbin/iwevent /sbin/ cpifexists /sbin/iwgetid /sbin/ cpifexists /sbin/iwlist /sbin/ cpifexists /sbin/iwpriv /sbin/ cpifexists /sbin/iwspy /sbin/ # copy udev firmware agent mkdir -p $DESTDIR/lib/udev cp -ra /lib/udev/firmware* $DESTDIR/lib/udev/ >/dev/null 2>&1 if [ -d /lib/firmware/${TCOS_KERNEL} ];then firmwaredir="/lib/firmware/${TCOS_KERNEL}" mkdir -p "${DESTDIR}${firmwaredir}" else firmwaredir="/lib/firmware" mkdir -p "${DESTDIR}${firmwaredir}" fi # generic modules manual_add_modules arc4 manual_add_modules ecb manual_add_modules michael_mic manual_add_modules ieee80211 #manual_add_modules rc80211_simple manual_add_modules mac80211 manual_add_modules ieee80211_crypt manual_add_modules ieee80211softmac manual_add_modules ieee80211_crypt_tkip manual_add_modules ieee80211_crypt_wep manual_add_modules ieee80211_crypt_ccmp # copy kernel modules for mod in $TCOS_WIRELESS_MODS; do manual_add_modules $mod if [ "$mod" = "ipw2200" ]; then _echo " WIFI: Copying firmware of ipw2200" cp -ra ${firmwaredir}/ipw2200* ${DESTDIR}${firmwaredir} elif [ "$mod" = "ipw2100" ]; then _echo " WIFI: Copying firmware of ipw2100" cp -ra ${firmwaredir}/ipw2100* ${DESTDIR}${firmwaredir} elif [ "$mod" = "madwifi" ]; then _echo " WIFI: Copying madwifi modules" #ath-pci ath-hal wlan_tkip wlan_scan_sta ath-hal manual_add_modules ath-pci manual_add_modules ath-hal manual_add_modules wlan-tkip manual_add_modules wlan-scan-sta elif [ "$mod" = "ndiswrapper" ]; then _echo " WIFI: ndiswrapper not supported (perl based)" elif [ "$mod" = "zd1211" ]; then _echo " WIFI: Copying Zydas modules and firmware" manual_add_modules zd1211rw # firmware #mkdir -p $DESTDIR/lib/firmware/ cp -ra ${firmwaredir}/zd1211/ ${DESTDIR}${firmwaredir} cat << EOF > $DESTDIR/scripts/tcos-top/02zydas_firmware #!/bin/sh if [ "\$1" = "prereqs" ]; then exit 0 fi mkdir -p /usr/lib/hotplug/firmware/ ln -s ${firmwaredir}/zd1211/zd1211_ub /usr/lib/hotplug/firmware/zd1211-WS11Ub.fw ln -s ${firmwaredir}/zd1211/zd1211_uph /usr/lib/hotplug/firmware/zd1211-WS11UPh.fw ln -s ${firmwaredir}/zd1211/zd1211_uphm /usr/lib/hotplug/firmware/zd1211-WS11UPhm.fw ln -s ${firmwaredir}/zd1211/zd1211_uphr /usr/lib/hotplug/firmware/zd1211-WS11UPhR.fw ln -s ${firmwaredir}/zd1211/zd1211_ur /usr/lib/hotplug/firmware/zd1211-WS11Ur.fw EOF chmod +x $DESTDIR/scripts/tcos-top/02zydas_firmware elif [ "$mod" = "rt61" -o "$mod" = "rt2561" -o "$mod" = "rt61pci" ]; then _echo " WIFI: Copying firmware of rt61/2561" cp -ra ${firmwaredir}/rt2* ${DESTDIR}${firmwaredir} elif [ "$mod" = "rt73" -o "$mod" = "rt73usb" ]; then _echo " WIFI: Copying firmware of rt73" cp -ra ${firmwaredir}/rt7* ${DESTDIR}${firmwaredir} elif [ "$mod" = "bcm43xx" -o "$mod" = "broadcom" ]; then _echo " WIFI: Copying firmware of bcm43xx" [ -e /lib/firmware/bcm43* ] && cp -ra /lib/firmware/bcm43* ${DESTDIR}/lib/firmware cp -ra ${firmwaredir}/bcm43* ${DESTDIR}${firmwaredir} else _echo " WIFI: Trying to copy unknow firmware" cp -ra ${firmwaredir}/$mod* ${DESTDIR}${firmwaredir} 2>/dev/null fi # end of if module done # end of modules for loop if [ "$TCOS_WIRELESS_ENC" = "WEP" ]; then _echo " DEBUG: using WEP..." if [ ! $TCOS_WIRELESS_KEY ]; then _echo "" _echo " WARNING:" _echo " Configured Wireless with WEP encription, but TCOS_WIRELESS_KEY is empty" _echo " Put your wireless key into this var in a supported format (HEX or ASCII)." _echo " See: man iwconfig (section key)" _echo "" fi fi if [ "$TCOS_WIRELESS_ENC" = "WPA" ]; then cpifexists /sbin/wpa_action /sbin/ cpifexists /sbin/wpa_cli /sbin/ cpifexists /sbin/wpa_supplicant /sbin/ cpifexists /usr/bin/wpa_passphrase /sbin/ # need linked libs in /lib not /usr/lib for lib in $(_ldd /sbin/wpa_supplicant /sbin/wpa_action /sbin/wpa_cli /usr/bin/wpa_passphrase | awk '{print $3}' |grep ^/); do newlib=$(echo $lib | sed s/"\/i686\/cmov"//g | sed s/"\/tls"//g ) #_echo " DEBUG: WPA: copying lib=$lib newlib=$newlib" if [ -e $newlib ]; then if [ ! -e $DESTDIR/lib/$(basename $lib) ]; then cp $newlib $DESTDIR/lib/ #else # _echo " DEBUG: WPA: $newlib is in image, not copy." fi else _echo " DEBUG: WPA: ### ERROR ### $newlib or $lib not found !!!!" fi done copydir /etc/wpa_supplicant /etc/ cat << EOF > $DESTDIR/sbin/start-wpa.sh #!/bin/sh . /scripts/functions . /conf/tcos.conf . /conf/tcos-run-functions TCOS_NET_WIFI_ESSID=\$(read_cmdline_var "essid" "") TCOS_WIRELESS_DEV=\$1 if [ "\$TCOS_WIRELESS_DEV" = "" ]; then echo "Error, need a wireless network device name" echo " example: \$0 ath0" echo " example: \$0 wlan0" fi WPA_CONF=\$(ls /etc/wpa_supplicant/*conf 2>/dev/null) if [ "\$WPA_CONF" = "" ]; then psk=\$(wpa_passphrase "\${TCOS_NET_WIFI_ESSID}" "\${TCOS_WIRELESS_KEY}" | sed 's/[[:blank:]]//g' | awk -F"=" '/^psk=/ {print \$2}') WPA_CONF=/etc/wpa_supplicant/wpa_supplicant.conf cat << EOC > \$WPA_CONF ctrl_interface=/var/run/wpa_supplicant network={ ssid="\${TCOS_NET_WIFI_ESSID}" proto=\${TCOS_WIRELESS_ENC} key_mgmt=WPA-PSK psk=\$psk } EOC fi PID=/var/run/wpa_supplicant.\${TCOS_WIRELESS_DEV}.pid #WPA_RUN=/var/run/wpa_supplicant wpa_supplicant -B -P\$PID -i\${TCOS_WIRELESS_DEV} -c\${WPA_CONF} EOF chmod +x $DESTDIR/sbin/start-wpa.sh fi stat_after "Wireless support" fi