Please note: This project is no longer active. The website is kept online for historic purposes only.
If you´re looking for a Linux driver for your Atheros WLAN device, you should continue here .

UserDocs/Distro/RedHat: wifi

File wifi, 1.4 kB (added by anonymous, 13 years ago)

a more RHEL/FC native Init script that includes 'ad-hoc' mode

Line 
1 #!/bin/bash
2
3 BIN=/etc/sysconfig/network-scripts
4 IFACE=ath0
5 LOC=home
6 PROFILE=${IFACE}-${LOC}
7
8 . /etc/init.d/functions
9
10 if [ $# -lt 1 ] || [ $# -gt 2 ]; then
11   echo "usage: wifi <start|ad-hoc|stop|status> [iface]"
12   exit 1
13 fi
14
15 if [ $# -eq 2 ]; then
16   IFACE=$2
17 fi
18
19 if [ ! -f "$BIN/ifcfg-$PROFILE" ]; then
20   echo "wifi: $PROFILE: No such interface"
21   exit 1
22 fi 
23  
24 if [ "$1" = "start" ]; then
25   action $"Bringing down eth0:" sudo $BIN/ifdown eth0
26   action $"Bringing up $PROFILE:" sudo $BIN/ifup $PROFILE
27   exit
28 fi
29
30 if [ "$1" = "ad-hoc" ]; then
31   action $"Bringing down eth0:" sudo $BIN/ifdown eth0
32   sudo ifconfig ath0 up
33   echo iwlist scan reports the following WiFi networks:
34   sudo iwlist scan 2>&1 | grep ESS | perl -ane '$_=~s/^\s+ESSID:/  /;print'
35   echo -e "WiFi network: \c"
36   read essid
37   echo -e "WEP key: \c"
38   read key
39   echo -n $"Bringing up $IFACE:"
40   sudo iwconfig $IFACE essid "$essid" > /dev/null 2>&1
41   if [ "X$key" != "X" ]; then
42     sudo iwconfig $IFACE key "s:$key" > /dev/null 2>&1
43   fi
44   echo_success; echo
45   echo -n $"Bringing up DHCP client: "
46   addr=`sudo dhclient 2>&1 | egrep '^bound to'`;
47   echo_success; echo
48   echo $addr
49   exit
50 fi
51
52 if [ "$1" = "stop" ]; then
53   action $"Bringing down $PROFILE:" sudo $BIN/ifdown $PROFILE
54   action $"Bringing up eth0:"     sudo $BIN/ifup eth0
55   exit
56 fi
57
58
59 if [ "$1" = "status" ]; then
60   sudo ifconfig $IFACE
61   exit
62 fi
63
64 echo "usage: wifi <start|ad-hoc|stop|status> [iface]"
65 exit 1
66