Magellan Linux

Diff of /trunk/initscripts/sysvinit/rc/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 270 by niro, Tue Oct 11 11:19:58 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.10 2005-10-11 11:19:58 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     ${CURS_UP}
145     ${SET_WWCOL}
146     echo "[AUTH: WEP]"
147    
148     iwconfig "${iface}" enc on
149     [[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}"
150     [[ -n ${WIRELESS_KEY} ]] && iwconfig "${iface}" key "${WIRELESS_KEY}"
151     [[ -n ${WIRELESS_KEY_ASCII} ]] && iwconfig "${iface}" key s:"${WIRELESS_KEY_ASCII}"
152    }
153    
154    config_wireless_wpa()
155    {
156     local iface="$1"
157    
158     if [[ -z ${iface} ]]
159     then
160     echo "WPA: no \$iface given. Aborting setup."
161     return 1
162     fi
163    
164     if [ ! -x /sbin/wpa_supplicant ]
165     then
166     echo "WPA: wpa_supplicant not installed. Aborting setup."
167     return 1
168     fi
169    
170     ${CURS_UP}
171     ${SET_WWCOL}
172     echo "[AUTH: WPA]"
173    
174     # get default settings
175     [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
176    
177     # check the configuration
178     [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto
179     [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel
180     if [[ -z ${WIRELESS_WPA_DRIVER} ]]
181     then
182     echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup."
183     return 1
184     fi
185    
186     # write a config with the settings from net.${iface}
187     # only wpa-psk ! all other needs manual setup
188     if [[ ${WIRELESS_WPA_AUTOCONF} = true ]]
189     then
190     # write default cfg from skeleton
191     cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG}
192    
193     # setup the network entry
194     sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \
195     -e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \
196     ${WIRELESS_WPA_CONFIG}
197     fi
198    
199     # now run the wpa_supplicant dameon
200     wpa_supplicant -B \
201     -D"${WIRELESS_WPA_DRIVER}" \
202     -c"${WIRELESS_WPA_CONFIG}" \
203     -i"${iface}" \
204     ${WIRELESS_WPA_OPTS}
205    
206     # echo wait 5 seconds
207     echo "    Waiting 5 seconds to retrieve authentification reply ... "
208     sleep 5
209    }
210    
211    setup_wireless_extensions()
212    {
213     local iface="$1"
214    
215     if [[ -z ${iface} ]]
216     then
217     echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup."
218     return 1
219     fi
220    
221     echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... "
222    
223     [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"
224     [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"
225     [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"
226     [[ -n ${WIRELESS_FREQUENCY} ]] && iwconfig "${iface}" freq "${WIRELESS_FREQUENCY}"
227     [[ -n ${WIRELESS_MODE} ]] && iwconfig "${iface}" mode "${WIRELESS_MODE}"
228     [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"
229    
230     case "${WIRELESS_AUTH_MODE}" in
231     wpa) config_wireless_wpa "${iface}" ;;
232     wep|on) config_wireless_wep "${iface}" ;;
233     off) iwconfig "${iface}" enc off ;;
234     esac
235    }
236    
237  networking_start()  networking_start()
238  {  {
239   local iface dns   local iface dns
# Line 142  networking_start() Line 245  networking_start()
245   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
246   checkconfig   checkconfig
247    
  echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."  
   
248   # setup mac   # setup mac
249   [ -n "${FORCE_MAC_TO}" ] && ifconfig ${iface} hw ether "${FORCE_MAC_TO}"   if [ -n "${FORCE_MAC_TO}" ]
250     then
251     echo -e ${COLOREDSTAR}"Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... "
252     ifconfig "${iface}" hw ether "${FORCE_MAC_TO}"
253     evaluate_retval
254     fi
255    
256     # activate the interface
257     ifconfig "${iface}" up
258    
259     # now configure wireless_extensions
260     [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}"
261    
262     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."
263    
264   # setup static or dhcp   # setup static or dhcp
265   case ${NETWORKING} in   case ${NETWORKING} in
# Line 184  networking_start() Line 298  networking_start()
298   echo "nameserver ${dns}" >> /etc/resolv.conf   echo "nameserver ${dns}" >> /etc/resolv.conf
299   done   done
300   fi   fi
   
  # setup wlan extensions  
  if [ -x /usr/sbin/iwconfig ]  
  then  
  [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"  
  [[ -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}"  
  fi  
301   done   done
302  }  }
303    
# Line 236  networking_stop() Line 327  networking_stop()
327   ${CURS_UP}   ${CURS_UP}
328   ${SET_WWCOL}   ${SET_WWCOL}
329   echo "[$(basename ${DHCP_PROG})]"   echo "[$(basename ${DHCP_PROG})]"
330   ${DHCP_PROG} ${DHCP_STOP}   ${DHCP_PROG} ${DHCP_STOP} "${iface}"
331   evaluate_retval   evaluate_retval
332   fi   fi
333    
334     # shutdown wpa_supplicant daemon
335     if [[ -n $(pidof wpa_supplicant) ]]
336     then
337     killall wpa_supplicant
338     fi
339   done   done
340    
341     # remove state dir
342     if [ -d /var/run/wpa_supplicant ]
343     then
344     rm -rf /var/run/wpa_supplicant
345     fi
346  }  }
347    
348  case $1 in  case $1 in

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