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 275 by niro, Fri Oct 21 15:24:25 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.11 2005-10-21 15:24:25 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     # remove old state dir
200     [ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant
201    
202     # now run the wpa_supplicant dameon
203     wpa_supplicant -B \
204     -D"${WIRELESS_WPA_DRIVER}" \
205     -c"${WIRELESS_WPA_CONFIG}" \
206     -i"${iface}" \
207     ${WIRELESS_WPA_OPTS}
208    
209     # echo wait 5 seconds
210     echo "    Waiting 5 seconds to retrieve authentification reply ... "
211     sleep 5
212    }
213    
214    setup_wireless_extensions()
215    {
216     local iface="$1"
217    
218     if [[ -z ${iface} ]]
219     then
220     echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup."
221     return 1
222     fi
223    
224     if [[ -n ${WIRELESS_BITRATE} ]] ||
225     [[ -n ${WIRELESS_CHANNEL} ]] ||
226     [[ -n ${WIRELESS_ESSID} ]] ||
227     [[ -n ${WIRELESS_FREQUENCY} ]] ||
228     [[ -n ${WIRELESS_MODE} ]] ||
229     [[ -n ${WIRELESS_NICK} ]] ||
230     [[ -n ${WIRELESS_AUTH_MODE} ]]
231     then
232     echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... "
233     fi
234    
235     [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"
236     [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"
237     [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"
238     [[ -n ${WIRELESS_FREQUENCY} ]] && iwconfig "${iface}" freq "${WIRELESS_FREQUENCY}"
239     [[ -n ${WIRELESS_MODE} ]] && iwconfig "${iface}" mode "${WIRELESS_MODE}"
240     [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"
241    
242     case "${WIRELESS_AUTH_MODE}" in
243     wpa) config_wireless_wpa "${iface}" ;;
244     wep|on) config_wireless_wep "${iface}" ;;
245     off) iwconfig "${iface}" enc off ;;
246     esac
247    }
248    
249  networking_start()  networking_start()
250  {  {
251   local iface dns   local iface dns
# Line 142  networking_start() Line 257  networking_start()
257   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
258   checkconfig   checkconfig
259    
  echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."  
   
260   # setup mac   # setup mac
261   [ -n "${FORCE_MAC_TO}" ] && ifconfig ${iface} hw ether "${FORCE_MAC_TO}"   if [ -n "${FORCE_MAC_TO}" ]
262     then
263     echo -e ${COLOREDSTAR}"Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... "
264     ifconfig "${iface}" hw ether "${FORCE_MAC_TO}"
265     evaluate_retval
266     fi
267    
268     # activate the interface
269     ifconfig "${iface}" up
270    
271     # now configure wireless_extensions
272     [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}"
273    
274     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."
275    
276   # setup static or dhcp   # setup static or dhcp
277   case ${NETWORKING} in   case ${NETWORKING} in
# Line 153  networking_start() Line 279  networking_start()
279   ${CURS_UP}   ${CURS_UP}
280   ${SET_WWCOL}   ${SET_WWCOL}
281   echo "[DHCP]"   echo "[DHCP]"
282   loadproc ${DHCP_PROG} ${DHCP_START}   loadproc ${DHCP_PROG} ${DHCP_START} "${iface}"
283   ;;   ;;
284   static|STATIC)   static|STATIC)
285   ${CURS_UP}   ${CURS_UP}
# Line 184  networking_start() Line 310  networking_start()
310   echo "nameserver ${dns}" >> /etc/resolv.conf   echo "nameserver ${dns}" >> /etc/resolv.conf
311   done   done
312   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  
313   done   done
314  }  }
315    
# Line 236  networking_stop() Line 339  networking_stop()
339   ${CURS_UP}   ${CURS_UP}
340   ${SET_WWCOL}   ${SET_WWCOL}
341   echo "[$(basename ${DHCP_PROG})]"   echo "[$(basename ${DHCP_PROG})]"
342   ${DHCP_PROG} ${DHCP_STOP}   ${DHCP_PROG} ${DHCP_STOP} "${iface}"
343   evaluate_retval   evaluate_retval
344   fi   fi
345    
346     # shutdown wpa_supplicant daemon
347     if [[ -n $(pidof wpa_supplicant) ]]
348     then
349     killall wpa_supplicant
350     fi
351   done   done
352    
353     # remove state dir
354     if [ -d /var/run/wpa_supplicant ]
355     then
356     rm -rf /var/run/wpa_supplicant
357     fi
358  }  }
359    
360  case $1 in  case $1 in

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