3 #########################################
6 # acx100.sourceforge.net #
7 # edited by arnie <urnotwelcome@gmx.de> #
8 #########################################
9 # with modifications by craig #
10 # summary at end of file #
11 #########################################
15 # syntax is: VARIABLENAME=VALUE, with _no_ spaces in between
16 # make sure to _preserve_ any double-quotes (")
17 # text beginning with the comment delimiter (#) is ignored
18 # make sure to _preserve_ at least one space before any
19 # comment delimiters (#) that do not begin a line
20 # "uncommenting" a line means to remove it's leading "#" character
22 ESSID
="network_down" # THIS IS CASE SeNsItIvE!! any == associate to any ESSID
23 # Default rate configured as 11Mbps to not cause speed problems (while
24 # using auto rate) or connection problems (while not using auto rate)
25 # with non-22Mbps hardware...
27 AUTORATE
=1 # only disable auto rate if you know what you're doing...
28 CHAN
=1 # it's useful to try to stick to channels 1, 6 or 11 only, since these don't overlap with other channels
29 #SHORTPREAMBLE=1 # set a value of 1 in order to force "Short Preamble" (incompatible with very old WLAN hardware!) instead of peer autodetect
30 #TXPOWER=20 # 0..20 (dBm) (18dBm is firmware default) overly large setting might perhaps destroy your radio eventually!
31 MODE
=Managed
# Managed for infrastructure, Ad-hoc for peer-to-peer. NOTE: Auto mode is not supported any more, you HAVE to select a specific mode!
32 DEBUG
=0xb # 0xffff for maximum debug info, 0 for none
35 # ascii keys (passphrase) should look like this: KEY="s:asciikey"
36 # hex keys should look like this: KEY="4378c2f43a"
38 # most wep users will want to use this line
41 # alternatively, you can uncomment and use these lines to
42 # set all 4 possible WEP keys
43 #KEY1="1234567890" #WEP64
47 # you must select which of the 4 keys above to use here:
48 #KEY="[1]" # for KEY1, "[2]" for KEY2, etc
50 ALG
=open
# open == Open System, restricted == Shared Key
54 USE_DHCP
=0 # set to 1 for auto configuration instead of fixed IP setting
56 IP
=192.168.1.98 # set this if you did not set USE_DHCP=1
57 NETMASK
=255.255.255.0 # set this if you did not set USE_DHCP=1
58 GATEWAY
=192.168.1.254 # set this if you did not set USE_DHCP=1
60 LED_OFF
=1 # set to 1 to turn off the power LED to save power
62 MTU_576
=0 # set to 1 if you have buffer management problems
64 # DO NOT EDIT BELOW THIS LINE
65 ##################################################################
68 if test "$UID" != "0"; then echo "You are not root. To insert the module into your kernel, you need to be root. Enter su and try again. Bailing..."; exit 1; fi
72 MODPROBE
=`which modprobe`
73 IFCONF
=`which ifconfig`
74 IWCONF
=`which iwconfig`
77 SCRIPT_AT
=`dirname $0`
79 # while we check for all 3, we run them in this
80 # "preferred" order: dhcpcd, pump, dhclient
81 # so if more than one exists it's ok
83 which dhcpcd
&> /dev
/null
84 if [ $?
-eq 0 ]; then DHCPCD
=`which dhcpcd`; fi
86 which pump
&> /dev
/null
87 if [ $?
-eq 0 ]; then PUMP
=`which pump`; fi
89 which dhclient
&> /dev
/null
90 if [ $?
-eq 0 ]; then DHCLIENT
=`which dhclient`; fi
92 if test -z "$SYNC"; then echo "sync not found. Go get a sane Linux system. Bailing..."; exit 1; fi
93 if test -z "$INSMOD"; then echo "insmod not found. Go get a sane Linux system. Bailing..."; exit 1; fi
94 if test -z "$IFCONF"; then echo "ifconfig not found. I can insert the module for you, but you won't be able to configure your interface."; CONTINUE
=ASK
; fi
95 if test -z "$IWCONF"; then echo "iwconfig not found. Make sure it is installed. The interface might work without, though."; CONTINUE
=ASK
; fi
97 if test -n "$CONTINUE"; then echo -n "Problems encountered. Do you want to continue? [n] "; read ANSWER
98 case $ANSWER in ( y | Y | Yes | YES |
yes | j | J | ja | Ja | JA
) ;;
105 MODULE_AT
="${SCRIPT_AT}/../src/acx_pci.o"
108 MODULE_AT
="${SCRIPT_AT}/../src/acx_pci.ko"
112 if test ! -r "$MODULE_AT"; then echo "Module not found or not readable.
113 Have you built it? This script expects it to be at ../src/acx_pci.[k]o, relative to the script's location. Bailing..."; exit 1; fi
115 # check whether any file name of the required main firmware file is
116 # available in the acx100/firmware or global firmware directory
118 # FIRMWARE_AT has to be given as an absolute path!!
119 for FIRMWARE_AT
in "${SCRIPT_AT}/../firmware" "/usr/share/acx"; do
120 for FW_FILE
in WLANGEN.BIN TIACX111.BIN FwRad16.bin FW1130.BIN
; do
121 if test -r "$FIRMWARE_AT/$FW_FILE"; then
122 #echo A firmware file has been found at "$FIRMWARE_AT/$FW_FILE"
129 if test "$FW_FOUND" != "1"; then
130 echo "Firmware not found or not readable. Have you placed it in the firmware directory or run make extract_firmware once? This script expects it to be either at ../firmware/WLANGEN.BIN (or ../firmware/TIACX111.BIN for the ACX111 chip), relative to the script's location, OR have you placed it in the default directory:/usr/share/acx?. Bailing...";
134 if test $AUTORATE != "1"; then
135 if test "$RATE" != "11M"; then echo "Transfer rate is not set to 11
136 Mbps, but $RATE (and not using auto rate either). If something doesn't work, try 11 Mbps or auto rate."; fi
139 test "$AUTORATE" = "1" && AUTO
=auto || AUTO
=
141 # for better debugging
143 #echo 8 > /proc/sys/kernel/printk
151 DEV
=wlan0
# this may become wlan1, wlan2, etc depending on if any other wlanX devices are found
153 if test -n "`lsmod | grep acx_pci`"; then ${SCRIPT_AT}/stop_net
;fi
155 # now that the interface is "down", let's also check for and remove
156 # those *really* old modules that might be supplied with some distributions
158 lsmod |
grep acx100_pci
&> /dev
/null
159 if test "$?" = "0"; then
161 echo "NOTICE: Found a very old version of the driver loaded (acx100_pci), removing."
162 # we could also add the old module's name to the blacklist, though this
163 # only benefits hotplug devices and might be considered invasive
164 # echo acx100_pci >> /etc/hotplug/blacklist
167 # before inserting the module, let's check for the presence of existing wlan devices
168 # and if necessary, adjust our $DEV variable to be wlan1, wlan2, etc.
169 # these could be other wireless drivers' devs, or the device created by acx_usb
171 MAX_WLANS
=9 # failsafe break counter
174 # at this point $DEV is always "wlan0"
175 $IFCONF $DEV &> /dev
/null
176 if test "$?" = "0"; then
177 echo -n "$DEV exists, "
178 DIGIT
=`echo $DEV | cut -d 'n' -f 2`
179 DIGIT
=`expr $DIGIT + 1`
181 echo -n "trying $DEV..."
188 if test $MAX_WLANS -eq 0; then break;fi
189 MAX_WLANS
=`expr $MAX_WLANS - 1`
192 $MODPROBE -q firmware_class
# Linux 2.6.x hotplug firmware loading support
193 $INSMOD $MODULE_AT debug
=$DEBUG firmware_dir
=$FIRMWARE_AT
194 if test "$?" = "0"; then echo "Module successfully inserted."; else echo "Error while inserting module! Bailing..."; exit 1; fi
197 # before we get too involved in trying to setup $DEV, let's verify that it exists
198 $IFCONF $DEV &> /dev
/null
199 if test "$?" = "0"; then # $DEV exists
201 if test -n "$IWCONF"; then
203 if test -n "$RATE"; then
204 echo Setting rate to
$RATE $AUTO.
205 $IWCONF $DEV rate
$RATE $AUTO
206 test "$?" != "0" && echo Failed.
208 if test -n "$CHAN"; then
209 echo Setting channel
$CHAN.
210 $IWCONF $DEV channel
$CHAN
211 test "$?" != "0" && echo Failed.
213 if test -n "$SHORTPREAMBLE"; then
214 echo Setting short preamble to
$SHORTPREAMBLE.
215 $IWPRIV $DEV SetSPreamble
$SHORTPREAMBLE
216 test "$?" != "0" && echo Failed.
219 if test -n "$TXPOWER"; then
220 echo Setting Tx power level to
$TXPOWER dBm.
221 $IWCONF $DEV txpower
$TXPOWER
222 test "$?" != "0" && echo Failed.
226 echo Going to try to
join or setup ESSID
$ESSID.
227 $IWCONF $DEV essid
"$ESSID"
228 test "$?" != "0" && echo Failed.
230 if test -n "$MODE"; then
231 echo Setting mode to
$MODE.
232 $IWCONF $DEV mode
$MODE
233 test "$?" != "0" && echo Failed.
237 if test -n "$KEY1"; then
238 echo Setting key
1 to
$KEY1, algorithm
$ALG.
239 $IWCONF $DEV key
$ALG "$KEY1" [1]
240 test "$?" != "0" && echo Failed.
243 if test -n "$KEY2"; then
244 echo Setting key
2 to
$KEY2, algorithm
$ALG.
245 $IWCONF $DEV key
$ALG "$KEY2" [2]
246 test "$?" != "0" && echo Failed.
249 if test -n "$KEY3"; then
250 echo Setting key
3 to
$KEY3, algorithm
$ALG.
251 $IWCONF $DEV key
$ALG "$KEY3" [3]
252 test "$?" != "0" && echo Failed.
255 if test -n "$KEY4"; then
256 echo Setting key
4 to
$KEY4, algorithm
$ALG.
257 $IWCONF $DEV key
$ALG "$KEY4" [4]
258 test "$?" != "0" && echo Failed.
261 # this is now placed after the "KEY%D" stuff
262 # to support the "KEY=[1]" option
264 if test -n "$KEY"; then
265 echo Setting key to
$KEY, algorithm
$ALG.
266 $IWCONF $DEV key
"$KEY" $ALG
267 test "$?" != "0" && echo Failed.
270 fi # end "if found(iwconfig)"
272 # for notebook use - a power LED is sooo useless anyway ;-))
273 if test "$LED_OFF" -eq 1; then
274 test -n "$IWPRIV" && "$IWPRIV" $DEV SetLEDPower
0
275 echo Setting power LED to off.
278 # It shouldn't hurt to bring the device up, and dhcp seems to like it that way
282 # if they want dhcp or they've set to managed mode, then we
283 # take up to 10 seconds to wait for something to show up
284 # in iwconfig besides zeros, we don't want to give the user
285 # the wrong impression re: success/failure and mainly we don't
286 # want to bother with a dhcp attempt without association
287 # we could also use /proc/driver/acx_$DEV instead ??
289 # check MODE for some form of the word "managed", case-insensitive
290 echo $MODE |
grep -ic managed
&> /dev
/null
292 if test "$?" = "0" -o $USE_DHCP -eq 1; then # begin test for association
294 echo -n "Waiting for association..."
298 echo -n "$WAIT_ASSOC "
300 if test "`$IWCONF $DEV | grep -c 00:00:00:00:00:00`" = "0"; then
303 # ok, have association, now verify that the card associated with
304 # the desired AP, it could easily have found a stray linksys instead ;^}
305 if test -n "$ESSID"; then
306 echo "$ESSID" |
grep -ic any
&> /dev
/null
# don't bother checking "essid=any"
307 if test "$?" = "0" -a "`$IWCONF $DEV | grep -c $ESSID`" = "0"; then
308 echo "NOTICE: $DEV associated, but NOT with $ESSID!"
314 WAIT_ASSOC
=`expr $WAIT_ASSOC - 1`
316 if test "$WAIT_ASSOC" = "0"; then
318 # if they wanted dhcp, tell them the bad news
319 if test $USE_DHCP -eq 1; then
320 echo "Error: $DEV failed to associate, can't use DHCP for IP address."
326 # we *could* issue an iwconfig here at the end of each loop:
327 # $IWCONF $DEV essid $ESSID
328 # I'm not sure if it would help or hinder...it isn't necessary w/my hardware
330 sleep 1 # give it a second
332 fi # end test for association, if mode=managed or USE_DHCP=1
335 if test $USE_DHCP -eq 1; then
336 # now we fetch an IP address from DHCP
338 if test -n "$DHCPCD"; then
339 echo -n "Attempting to use $DHCPCD for DHCP, this may take a moment..."
340 rm -f /etc
/dhcpc
/dhcpcd-
$DEV.pid
> /dev
/null
341 $DHCPCD -d $DEV -t 5 &> /dev
/null
342 if test "$?" = "0"; then
344 echo "Interface has been set up successfully.";
347 # no dhcpcd was found, next we try pump:
348 elif test -n "$PUMP"; then
349 echo -n "Attempting to use $PUMP for DHCP, this may take a moment..."
350 $PUMP -i $DEV &> /dev
/null
351 if test "$?" = "0"; then
353 echo "Interface has been set up successfully.";
356 # no dhcpcd or pump was found, finally we try dhclient;
357 elif test -n "$DHCLIENT"; then
358 echo -n "Attempting to use $DHCLIENT for DHCP, this may take a moment..."
359 rm -f /var
/run
/dhclient.pid
360 $DHCLIENT $DEV &> /dev
/null
361 if test "$?" = "0"; then
363 echo "Interface has been set up successfully.";
366 else # dhcpcd, pump, and dhclient not found, inform user and bail
367 echo "ERROR: USE_DHCP=1 , but no dhcp clients could be found"
370 fi #end check for usable dhcp client
371 else # wants manual config
372 # Hehe, this can be done after iwconfigs now :)
373 $IFCONF $DEV $IP netmask
$NETMASK
374 if test "$?" != "0"; then
375 echo "Error in \"$IFCONF $DEV $IP netmask $NETMASK\". Bailing..."; exit 1;
377 echo "Interface has been set up successfully.";
378 test -n "$GATEWAY" && $ROUTE add default gw
$GATEWAY $DEV
380 fi # end if USE_DHCP=1
382 # ugly workaround for buffer management problems
383 if test "$MTU_576" -eq 1; then
384 echo "Setting mtu down to 576. NOTE that e.g. IPv6 would need >= 1280, so make sure you're doing the right thing here!"
385 test -n "$IFCONF" && "$IFCONF" $DEV mtu
576
386 if test "$?" != "0"; then echo "Error in \"$IFCONF $DEV mtu 576\". Bailing..."; exit 1; fi
389 else # $DEV is not found by ifconfig
390 echo "Error: Failed to create device: $DEV...bailing."
392 fi # end test for $DEV exists
399 ##############################################################
400 # summary of craig's changes to pf33's start_net:
402 # added SET_LED and MTU_576 vars, moved DEV below the do-not-edit line
403 # changed KEY0-KEY3 vars to KEY1-KEY4 to match iwconfig's scheme
404 # added a line for selecting a numbered key eg: "KEY=[1]"
405 # moved setting wep key to last in the order for above to work
406 # added attempt to automagically find/use a dhcp client
407 # added checking for firmware in /usr/share/acx before bailing
408 # check for and unload the old acx100_pci module if present
409 # don't assume $DEV is going to always be wlan0 (needs more work)
410 # don't assume that $DEV exists, even after a successful module load
411 # if MODE=managed || USE_DHCP=1, wait for association
412 # upon assoc, test for correct SSID if one was specified
413 # added $DEV to route add default gw command
414 ##############################################################