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: ifup-ath

File ifup-ath, 6.2 kB (added by Anonymous, 13 years ago)

This will automate through the "ifup athX" mechanism. This script assumes wireless-tools, wpa_supplicant, and the madwifi drivers are properly installed.

Line 
1 #!/bin/bash
2 # This is a modified version of the Red Hat ifup/ifup-eth
3 # shipped with FC4 for use with Madwifi network devices.
4 # Modified by Greg Davey
5 # original copyright follows
6
7 # Network Interface Configuration System
8 # Copyright (c) 1996-2005 Red Hat, Inc. all rights reserved.
9 #
10 # This software may be freely redistributed under the terms of the GNU
11 # public license.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.5
16
17 . /etc/init.d/functions
18 cd /etc/sysconfig/network-scripts
19 . network-functions
20 [ -f ../network ] && . ../network
21
22 CONFIG=${1}
23 need_config ${CONFIG}
24 source_config
25
26 if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then
27     DYNCONFIG=true
28 fi
29
30 #load device modules
31 is_available ${REALDEVICE}
32
33 if [ -z ${DYNCONFIG} ] ; then
34     ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} up
35 else
36     ifconfig ${DEVICE} up
37 fi
38
39 echo
40 #############################################################33
41
42 # This is a bit hackish, but should do the job right...
43 if [ -n "$ESSID" -o -n "$MODE" ] ; then
44     NICKNAME=`/bin/hostname`
45     iwconfig ${DEVICE} nick "$NICKNAME" >/dev/null 2>&1
46 fi
47
48 if [ -n "$MODE" ] ; then
49     iwconfig ${DEVICE} mode $MODE
50 fi
51
52 if [ -n ${WIRELESS_RATE} ] ; then
53     iwconfig ${DEVICE} rate ${WIRELESS_RATE}
54 fi
55
56 #    if [ "$ENCRYPTION" != "WPA" -a "$ENCRYPTION" != "WPA2" ] ; then
57 #This won't work at all with multiple wireless cards needing wpa_supplicant.
58 #Please hack me.
59 pkill wpa_supplicant
60 #    fi
61
62 if [ -n "$ENCRYPTION" ] ; then
63     if [ "$ENCRYPTION" = "WPA" -o "$ENCRYPTION" = "WPA2" ] ; then
64         wpa_passphrase "${ESSID}" "${WPA_PASSPHRASE}" > /etc/wpa_supplicant_${DEVICE}.conf
65         chmod 620 /etc/wpa_supplicant_${DEVICE}.conf
66     fi
67
68     if [ "$ENCRYPTION" = "WEP" ] ; then
69         if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
70             [ -n "$KEY1" ] && iwconfig ${DEVICE} key [1] $KEY1
71             [ -n "$KEY2" ] && iwconfig ${DEVICE} key [2] $KEY2
72             [ -n "$KEY3" ] && iwconfig ${DEVICE} key [3] $KEY3
73             [ -n "$KEY4" ] && iwconfig ${DEVICE} key [4] $KEY4
74             if [ -n "$DEFAULTKEY" ] ; then
75                 iwconfig ${DEVICE} key [${DEFAULTKEY}]
76             else
77                 iwconfig ${DEVICE} key [1]
78             fi
79             echo "${ENCRYPTION} enabled!"
80         fi
81        
82     fi
83
84     if [ "${ENCRYPTION}" != "WPA" -a "${ENCRYPTION}" != "WPA2" ] ; then
85         if [ -n "${SECURITYMODE}" ] ; then
86             iwconfig ${DEVICE} enc ${SECURITYMODE}
87         fi
88     fi
89
90     if [ "$ENCRYPTION" = "NONE" ] ; then
91         iwconfig ${DEVICE} key off
92     fi
93 else
94     iwconfig ${DEVICE} key off
95 fi
96
97 # More specific parameters passed directly to IWCONFIG
98 if [ -n "$IWCONFIG" ] ; then
99     iwconfig ${DEVICE} $IWCONFIG
100 fi
101
102 if [ -n "$IWPRIV" ] ; then
103     iwpriv ${DEVICE} $IWPRIV
104 fi
105
106 # ESSID need to be last : most device re-perform the scanning/discovery
107 # when this is set, and things like encryption keys are better be
108 # defined if we want to discover the right set of APs/nodes.
109 if [ -n "$ESSID" ] ; then
110     iwconfig ${DEVICE} essid "$ESSID"
111 else
112     # use any essid
113     iwconfig ${DEVICE} essid any
114 fi
115
116 if [ -n ${WIRELESS_CARD_MODE} ] ; then
117     iwpriv ${DEVICE} mode ${WIRELESS_CARD_MODE}
118 fi
119
120 if [ -n ${WIRELESS_TURBO_MODE} ] ; then
121     iwpriv ${DEVICE} turbo ${WIRELESS_TURBO_MODE}
122 fi
123
124 if [ "$ENCRYPTION" = "WPA" -o "$ENCRYPTION" = "WPA2" ] ; then
125     if [ "$ENCRYPTION" = "WPA" ] ; then
126         wpa_supplicant -Bw -Dmadwifi -i${DEVICE} -c/etc/wpa_supplicant_${DEVICE}.conf -pkey_mgmt=WPA-PSK -pproto=WPA
127     fi
128
129     if [ "$ENCRYPTION" = "WPA2" ] ; then
130         wpa_supplicant -Bw -Dmadwifi -i${DEVICE} -c/etc/wpa_supplicant_${DEVICE}.conf -pkey_mgmt=WPA-PSK -pproto=RSN
131     fi
132     echo "${ENCRYPTION} enabled!"
133 fi
134
135 if [ -n "${DYNCONFIG}" -a -x /sbin/dhclient ]; then
136     # Remove any temporary references which were previously added to dhclient config
137     if [ -w /etc/dhclient-${DEVICE}.conf ] ; then
138         LC_ALL=C grep -v "# temporary RHL ifup addition" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null
139         cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf
140         rm -f /etc/dhclient-${DEVICE}.conf.ifupnew
141     fi
142     if [[ "${PERSISTENT_DHCLIENT}" =  [yY1]* ]]; then
143        ONESHOT="";
144     else
145        ONESHOT="-1";
146     fi;
147     if [ -n "${DHCP_HOSTNAME}" ]; then
148        # Send a host-name to the DHCP server (requ. by some dhcp servers).
149        if [ -w /etc/dhclient-${DEVICE}.conf ] ; then
150            if ! LC_ALL=C grep "send *host-name *\"${DHCP_HOSTNAME}\"" /etc/dhclient-${DEVICE}.conf > /dev/null 2>&1 ; then
151                echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-${DEVICE}.conf
152            fi
153        elif ! [ -e /etc/dhclient-${DEVICE}.conf ] ; then
154            echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-${DEVICE}.conf
155        fi
156     fi
157     # allow users to use generic '/etc/dhclient.conf' (as documented in manpage!)
158     # if per-device file doesn't exist or is empty
159     if [ -s /etc/dhclient-${DEVICE}.conf ]; then
160        DHCLIENTCONF="-cf /etc/dhclient-${DEVICE}.conf";
161     else
162        DHCLIENTCONF='';
163     fi;
164     DHCLIENTARGS="${DHCLIENTARGS} ${ONESHOT} -q ${DHCLIENTCONF} -lf /var/lib/dhcp/dhclient-${DEVICE}.leases -pf /var/run/dhclient-${DEVICE}.pid"
165     echo
166     echo -n $"Determining IP information for ${DEVICE}..."
167     if check_link_down ${DEVICE}; then
168         echo $" failed; no link present.  Check cable?"
169         ip link set dev ${DEVICE} down >/dev/null 2>&1
170         exit 1
171     fi
172
173     if [ -n "$ETHTOOL_OPTS" ] ; then
174         /sbin/ethtool -s ${REALDEVICE} $ETHTOOL_OPTS
175     fi
176
177     if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then
178         echo $" done."
179     else
180         echo $" failed."
181         exit 1
182     fi
183 # end dynamic device configuration
184 else
185     if [ -n "${GATEWAY}" ] ; then
186         route add default gw ${GATEWAY}
187         echo "${DEVICE} gateway installed."
188     fi
189 fi
190
191 # IPv6 initialisation?
192 if [ "${NETWORKING_IPV6}" = "yes" ]; then
193     /etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG}
194     if [[ "${DHCPV6C}"  = [Yy1]* ]] && [ -x /sbin/dhcp6c ]; then
195         /sbin/dhcp6c ${DEVICE};
196         dhcp6_pid=(`/bin/ps -eo 'pid,args' | /bin/grep "dhcp6c ${DEVICE}" | egrep -v grep`);
197         echo ${dhcp6_pid[0]} > /var/run/dhcp6c_${DEVICE}.pid
198     fi
199 fi
200
201 exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2}