Magellan Linux

Diff of /trunk/magellan-initscripts/etc/rc.d/init.d/network

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 265 by niro, Sun Oct 9 22:31:13 2005 UTC revision 268 by niro, Mon Oct 10 18:43:03 2005 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.8 2005-10-09 22:31:13 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.9 2005-10-10 18:43:03 niro Exp $
3    
4  #%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k  #%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k
5  #%start: 20  #%start: 20
# Line 131  onboot_interface_list() Line 131  onboot_interface_list()
131   echo "${devices}"   echo "${devices}"
132  }  }
133    
134    config_wireless_wep()
135    {
136     local iface="$1"
137    
138     if [[ -z ${iface} ]]
139     then
140     echo "WEP: no \$iface given. Aborting setup."
141     return 1
142     fi
143    
144     iwconfig "${iface}" enc on
145     [[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}"
146     [[ -n ${WIRELESS_KEY} ]] && iwconfig "${iface}" key "${WIRELESS_KEY}"
147     [[ -n ${WIRELESS_KEY_ASCII} ]] && iwconfig "${iface}" key s:"${WIRELESS_KEY_ASCII}"
148    }
149    
150    config_wireless_wpa()
151    {
152     local iface="$1"
153    
154     if [[ -z ${iface} ]]
155     then
156     echo "WPA: no \$iface given. Aborting setup."
157     return 1
158     fi
159    
160     if [ ! -x /sbin/wpa_supplicant ]
161     then
162     echo "WPA: wpa_supplicant not installed. Aborting setup."
163     return 1
164     fi
165    
166     # get default settings
167     [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
168    
169     # check the configuration
170     [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto
171     [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel
172     if [[ -z ${WIRELESS_WPA_DRIVER} ]]
173     then
174     echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup."
175     return 1
176     fi
177    
178     # write a config with the settings from net.${iface}
179     # only wpa-psk ! all other needs manual setup
180     if [[ ${WIRELESS_WPA_AUTOCONF} = true ]]
181     then
182     # write default cfg from skeleton
183     cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG}
184    
185     # setup the network entry
186     sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \
187     -e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \
188     ${WIRELESS_WPA_CONFIG}
189     fi
190    
191     # now run the wpa_supplicant dameon
192     wpa_supplicant -B \
193     -D"${WIRELESS_WPA_DRIVER}" \
194     -c"${WIRELESS_WPA_CONFIG}" \
195     -i"${iface}" \
196     ${WIRELESS_WPA_OPTS}
197    }
198    
199    setup_wireless_extensions()
200    {
201     local iface="$1"
202    
203     if [[ -z ${iface} ]]
204     then
205     echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup."
206     return 1
207     fi
208    
209     [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"
210     [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"
211     [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"
212     [[ -n ${WIRELESS_FREQUENCY} ]] && iwconfig "${iface}" freq "${WIRELESS_FREQUENCY}"
213     [[ -n ${WIRELESS_MODE} ]] && iwconfig "${iface}" mode "${WIRELESS_MODE}"
214     [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"
215    
216     case "${WIRELESS_AUTH_MODE}" in
217     wpa) config_wireless_wpa "${iface}" ;;
218     wep|on) config_wireless_wep "${iface}" ;;
219     off) iwconfig "${iface}" enc off ;;
220     esac
221    }
222    
223  networking_start()  networking_start()
224  {  {
225   local iface dns   local iface dns
# Line 188  networking_start() Line 277  networking_start()
277   # setup wlan extensions   # setup wlan extensions
278   if [ -x /usr/sbin/iwconfig ]   if [ -x /usr/sbin/iwconfig ]
279   then   then
280   [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"   setup_wireless_extensions "${iface}"
  [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"  
  [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"  
  [[ -n ${WIRELESS_FREQUENCY} ]] && iwconfig "${iface}" freq "${WIRELESS_FREQUENCY}"  
  [[ -n ${WIRELESS_MODE} ]] && iwconfig "${iface}" mode "${WIRELESS_MODE}"  
  [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"  
  if [[ -n ${WIRELESS_AUTH_MODE} ]]  
  then  
  case ${WIRELESS_AUTH_MODE} in  
  wpa) echo "Using wpa";;  
  wep|on) iwconfig "${iface}" enc on ;;  
  off) iwconfig "${iface}" enc off ;;  
  *) echo "Unkown Wireless_Auth_Mode '${WIRELESS_AUTH_MODE}'." ;;  
  esac  
  fi  
  [[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}"  
  [[ -n ${WIRELESS_KEY} ]] && iwconfig "${iface}" key "${WIRELESS_KEY}"  
  [[ -n ${WIRELESS_KEY_ASCII} ]] && iwconfig "${iface}" key s:"${WIRELESS_KEY_ASCII}"  
281   fi   fi
282   done   done
283  }  }
# Line 239  networking_stop() Line 311  networking_stop()
311   ${DHCP_PROG} ${DHCP_STOP}   ${DHCP_PROG} ${DHCP_STOP}
312   evaluate_retval   evaluate_retval
313   fi   fi
314    
315     # shutdown wpa_supplicant daemon
316     if [[ -n $(pidof wpa_supplicant) ]]
317     then
318     killall wpa_supplicant
319     fi
320   done   done
321  }  }
322    

Legend:
Removed from v.265  
changed lines
  Added in v.268