Magellan Linux

Diff of /trunk/initscripts/sysvinit/rc/network

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

trunk/magellan-initscripts/etc/rc.d/init.d/network revision 268 by niro, Mon Oct 10 18:43:03 2005 UTC trunk/initscripts/sysvinit/rc/network revision 2307 by niro, Thu Jan 2 13:33:22 2014 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.9 2005-10-10 18:43:03 niro Exp $  # $Id$
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 10  Line 10 
10  #%before:  #%before:
11  #%after:  #%after:
12    
13  source /etc/sysconfig/rc  source /etc/conf.d/rc
14  source ${rc_functions}  source ${rc_functions}
15    source /etc/conf.d/network
16    
17    wait_online()
18    {
19     local timeout="1"
20     local iface="$2"
21    
22     (( timeout *= 10 ))
23    
24     while [ ! -e /sys/class/net/${iface} ]
25     do
26     (( timeout-- > 0 )) || return 1
27     sleep 0.1
28     done
29    
30     return 0
31    }
32    
33  # read values from files  # read values from files
34  read_value()  read_value()
# Line 24  read_value() Line 41  read_value()
41   # global   # global
42   local ONBOOT   local ONBOOT
43   local NETWORKING   local NETWORKING
44    
45   # static   # static
46   local IP   local IP
47   local NETMASK   local NETMASK
# Line 60  read_value() Line 77  read_value()
77   local WIRELESS_NICK   local WIRELESS_NICK
78   local WIRELESS_NWID   local WIRELESS_NWID
79   local WIRELESS_POWER   local WIRELESS_POWER
80     local WIRELESS_WPA_DRIVER
81    
82     local BRIDGE_INTERFACES
83     local BRIDGE_STP
84     local BRIDGE_AGEING_TIME
85     local BRIDGE_PRIORITY
86     local BRIDGE_FORWARD_DELAY
87     local BRIDGE_HELLO_TIME
88     local BRIDGE_MAX_MESSAGE_AGE
89     local BRIDGE_PATH_COST
90     local BRIDGE_PORT_PRIORITY
91    
92   source ${file}   source ${file}
93   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
# Line 68  read_value() Line 96  read_value()
96    
97  checkconfig()  checkconfig()
98  {  {
99   if [ -z "${NETWORKING}" ]   if [[ -z ${NETWORKING} ]]
100   then   then
101   echo "NETWORKING missing in net.${interface}, aborted"   rc_echo "NETWORKING missing in net.${iface}, aborted"
102   exit 1   exit 1
103   fi   fi
104    
105   case "${NETWORKING}" in   case "${NETWORKING}" in
106   static)   static)
107   if [ -z "${IP}" ]   if [[ -z ${IP} ]]
108   then   then
109   echo "IP missing in net.${interface}, aborted"   rc_echo "IP missing in net.${iface}, aborted"
110   exit 1   exit 1
111   fi   fi
112    
113   if [ -z "${NETMASK}" ]   if [[ -z ${NETMASK} ]]
114   then   then
115   echo -n "NETMASK missing in net.${interface}, "   rc_echo -n "NETMASK missing in net.${iface}, "
116   echo "using 255.255.255.0"   rc_echo "using ${DEFAULT_NETMASK}"
117   NETMASK=255.255.255.0   NETMASK="${DEFAULT_NETMASK}"
118   fi   fi
119    
120   if [ -z "${BROADCAST}" ]   if [[ -z ${BROADCAST} ]]
121   then   then
122   echo -n "BROADCAST missing in net.${interface}, "   rc_echo -n "BROADCAST missing in net.${iface}, "
123   echo "using default address"   rc_echo "using default address"
124   fi   fi
125   ;;   ;;
126    
127   dhcp)   dhcp)
128   if [ -z "${DHCP_PROG}" ]   if [[ -z ${DHCP_PROG} ]]
129   then   then
130   echo "DHCP_PROG missing in net.${interface}, aborted"   rc_echo -n "DHCP_PROG missing in net.${iface},"
131   exit 1   rc_echo "using default programm ${DEFAULT_DHCP_PROG}"
132     DHCP_PROG="${DEFAULT_DHCP_PROG}"
133   fi   fi
134     [[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}"
135     [[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}"
136   ;;   ;;
137    
138   esac   esac
# Line 117  onboot_interface_list() Line 148  onboot_interface_list()
148   # get list of all devices   # get list of all devices
149   for file in $@   for file in $@
150   do   do
151     iface="$(basename ${file} | sed s/net.//)"
152    
153     # exclude backup files and exclude net.routes and net.sample too
154     case "${iface}" in
155     *~) continue ;;
156     routes) continue ;;
157     sample) continue ;;
158     esac
159    
160   if [[ $(read_value ONBOOT ${file}) = yes ]]   if [[ $(read_value ONBOOT ${file}) = yes ]]
161   then   then
162   iface="$(basename ${file} | sed s/net.//)"   devices="${devices} ${iface}"
  # exclude backup files  
  case "${iface}" in  
  *~) ;;  
  *) devices="${devices} $(basename ${file} | sed s/net.//)" ;;  
  esac  
163   fi   fi
164   done   done
165    
# Line 137  config_wireless_wep() Line 172  config_wireless_wep()
172    
173   if [[ -z ${iface} ]]   if [[ -z ${iface} ]]
174   then   then
175   echo "WEP: no \$iface given. Aborting setup."   rc_echo "WEP: no \$iface given. Aborting setup."
176   return 1   return 1
177   fi   fi
178    
179     ${CURS_UP}
180     ${SET_WWCOL}
181     rc_echo "[AUTH: WEP]"
182    
183   iwconfig "${iface}" enc on   iwconfig "${iface}" enc on
184   [[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}"   [[ -n ${WIRELESS_KEY_LENGTH} ]] && iwconfig "${iface}" enc "${WIRELESS_KEY_LENGTH}"
185   [[ -n ${WIRELESS_KEY} ]] && iwconfig "${iface}" key "${WIRELESS_KEY}"   [[ -n ${WIRELESS_KEY} ]] && iwconfig "${iface}" key "${WIRELESS_KEY}"
# Line 153  config_wireless_wpa() Line 192  config_wireless_wpa()
192    
193   if [[ -z ${iface} ]]   if [[ -z ${iface} ]]
194   then   then
195   echo "WPA: no \$iface given. Aborting setup."   rc_echo "WPA: no \$iface given. Aborting setup."
196   return 1   return 1
197   fi   fi
198    
199   if [ ! -x /sbin/wpa_supplicant ]   if [ ! -x $(type -P wpa_supplicant) ]
200   then   then
201   echo "WPA: wpa_supplicant not installed. Aborting setup."   rc_echo "WPA: wpa_supplicant not installed. Aborting setup."
202   return 1   return 1
203   fi   fi
204    
205     ${CURS_UP}
206     ${SET_WWCOL}
207     rc_echo "[AUTH: WPA]"
208    
209   # get default settings   # get default settings
210   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
211    
212   # check the configuration   # check the configuration
213   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto
214   [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel   [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel
215   if [[ -z ${WIRELESS_WPA_DRIVER} ]]  
216   then   # use wext as default driver, do not abort here anymore
217   echo "WPA: WIRELESS_WPA_DRIVER given. Aborting setup."   [[ -z ${WIRELESS_WPA_DRIVER} ]] && WIRELESS_WPA_DRIVER=wext
  return 1  
  fi  
218    
219   # write a config with the settings from net.${iface}   # write a config with the settings from net.${iface}
220   # only wpa-psk ! all other needs manual setup   # only wpa-psk ! all other needs manual setup
# Line 182  config_wireless_wpa() Line 223  config_wireless_wpa()
223   # write default cfg from skeleton   # write default cfg from skeleton
224   cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG}   cat ${WIRELESS_WPA_SKEL} > ${WIRELESS_WPA_CONFIG}
225    
226     local wpa_proto
227     case ${WIRELESS_AUTH_MODE} in
228     wpa) wpa_proto="WPA" ;;
229     wpa2) wpa_proto="WPA2" ;;
230     esac
231    
232   # setup the network entry   # setup the network entry
233   sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \   sed -i -e "s:@WIRELESS_ESSID@:${WIRELESS_ESSID}:g" \
234   -e "s:@WIRELESS_KEY@:${WIRELESS_KEY}:g" \   -e "s:@WIRELESS_KEY@:${WIRELESS_KEY_ASCII}:g" \
235     -e "s:@WIRELESS_AUTH_MODE@:${wpa_proto}:g" \
236   ${WIRELESS_WPA_CONFIG}   ${WIRELESS_WPA_CONFIG}
237   fi   fi
238    
239     # remove old state dir
240     [ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant
241    
242   # now run the wpa_supplicant dameon   # now run the wpa_supplicant dameon
243   wpa_supplicant -B \   wpa_supplicant -B \
244   -D"${WIRELESS_WPA_DRIVER}" \   -D"${WIRELESS_WPA_DRIVER}" \
245   -c"${WIRELESS_WPA_CONFIG}" \   -c"${WIRELESS_WPA_CONFIG}" \
246   -i"${iface}" \   -i"${iface}" \
247   ${WIRELESS_WPA_OPTS}   ${WIRELESS_WPA_OPTS}
248    
249     # echo wait 5 seconds
250     rc_echo "    Waiting 5 seconds to retrieve authentification reply ... "
251     sleep 5
252  }  }
253    
254  setup_wireless_extensions()  setup_wireless_extensions()
# Line 202  setup_wireless_extensions() Line 257  setup_wireless_extensions()
257    
258   if [[ -z ${iface} ]]   if [[ -z ${iface} ]]
259   then   then
260   echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup."   rc_echo "WIRELESS_EXTENSIONS: no \$iface given. Aborting setup."
261   return 1   return 1
262   fi   fi
263    
264     if [[ -n ${WIRELESS_BITRATE} ]] ||
265     [[ -n ${WIRELESS_CHANNEL} ]] ||
266     [[ -n ${WIRELESS_ESSID} ]] ||
267     [[ -n ${WIRELESS_FREQUENCY} ]] ||
268     [[ -n ${WIRELESS_MODE} ]] ||
269     [[ -n ${WIRELESS_NICK} ]] ||
270     [[ -n ${WIRELESS_AUTH_MODE} ]]
271     then
272     rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... "
273     fi
274    
275   [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"   [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"
276   [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"   [[ -n ${WIRELESS_CHANNEL} ]] && iwconfig "${iface}" channel "${WIRELESS_CHANNEL}"
277   [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"   [[ -n ${WIRELESS_ESSID} ]] && iwconfig "${iface}" essid "${WIRELESS_ESSID}"
# Line 214  setup_wireless_extensions() Line 280  setup_wireless_extensions()
280   [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"   [[ -n ${WIRELESS_NICK} ]] && iwconfig "${iface}" nick "${WIRELESS_NICK}"
281    
282   case "${WIRELESS_AUTH_MODE}" in   case "${WIRELESS_AUTH_MODE}" in
283   wpa) config_wireless_wpa "${iface}" ;;   wpa|wpa2) config_wireless_wpa "${iface}" ;;
284   wep|on) config_wireless_wep "${iface}" ;;   wep|on) config_wireless_wep "${iface}" ;;
285   off) iwconfig "${iface}" enc off ;;   off) iwconfig "${iface}" enc off ;;
286     esac
287    }
288    
289    config_bridge_options()
290    {
291     local iface="$1"
292     local i
293     local port
294     local cost
295     local prio
296    
297     # enable spanning-tree protocol
298     case ${BRIDGE_STP} in
299     on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;;
300     *) rc_echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;;
301     esac
302    
303     # configure ageing time
304     if [[ ! -z ${BRIDGE_AGEING_TIME} ]]
305     then
306     brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}"
307     fi
308    
309     # configure bridge priority
310     if [[ ! -z ${BRIDGE_PRIORITY} ]]
311     then
312     brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}"
313     fi
314    
315     # configure forward delay
316     if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]]
317     then
318     brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}"
319     fi
320    
321     # configure hello time
322     if [[ ! -z ${BRIDGE_HELLO_TIME} ]]
323     then
324     brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}"
325     fi
326    
327     # configure maximal message age
328     if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]]
329     then
330     brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}"
331     fi
332    
333     # configure path cost for every port
334     if [[ ! -z ${BRIDGE_PATH_COST} ]]
335     then
336     for i in ${BRIDGE_PATH_COST}
337     do
338     port="${i%=*}"
339     cost="${i#*=}"
340     [[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}"
341     done
342     fi
343    
344     # configure port priority for every port
345     if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]]
346     then
347     for i in ${BRIDGE_PORT_PRIORITY}
348     do
349     port="${i%=*}"
350     prio="${i#*=}"
351     [[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}"
352     done
353     fi
354    }
355    
356    config_bridge_devices()
357    {
358     local iface="$1"
359     local method="$2"
360     local bport
361    
362     if [[ -z ${iface} ]]
363     then
364     rc_echo "BRIDGE: no \$iface given. Aborting setup."
365     return 1
366     fi
367    
368     if [[ -z ${method} ]]
369     then
370     rc_echo "BRIDGE: no \$method given. Aborting setup."
371     return 1
372     fi
373    
374     # first check for brctl
375     if [[ -z $(type -P brctl) ]]
376     then
377     rc_echo "brctl not found! Please install 'net-misc/bridge-utils'."
378     return 1
379     fi
380    
381     # check the config
382     if [[ -z ${BRIDGE_INTERFACES} ]]
383     then
384     rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup."
385     return 1
386     fi
387    
388     case ${method} in
389     add)
390     # setup the bridge device
391     brctl addbr "${iface}"
392     for bport in ${BRIDGE_INTERFACES}
393     do
394     # enter promiscous mode
395     ifconfig "${bport}" 0.0.0.0 promisc
396     # now setup the bridge
397     brctl addif "${iface}" "${bport}"
398     done
399     # configure all other options
400     config_bridge_options "${iface}"
401     ;;
402    
403     remove)
404     for bport in ${BRIDGE_INTERFACE}
405     do
406     # bring the interface down
407     ifconfig "${bport}" down
408     # remove the interface from the bridge
409     brctl delif "${iface}" "${bport}"
410     done
411     # bring the bridge down
412     brctl delbr "${iface}"
413     ;;
414   esac   esac
415    
416     # unset the bridge variable to be safe
417     unset BRIDGE_INTERFACES
418     # continue to setup generic networking
419    }
420    
421    config_routes()
422    {
423     local method="$1"
424     local message
425    
426     # only add and del are allowed
427     case ${method} in
428     add) message="Adding" ;;
429     del) message="Removing" ;;
430     *)
431     rc_echo "config_routes: unsupported \$method '${method}'."
432     exit 1
433     ;;
434     esac
435    
436     # adds/delete user routes
437     if [[ -f /etc/conf.d/net.routes ]]
438     then
439     ( cat /etc/conf.d/net.routes; echo ) | # make sure there is a LF at the end
440     while read route
441     do
442     case "${route}" in
443     \#*|"") continue ;;
444     esac
445     rc_print "${message} route ${COLBLUE}${route}${COLDEFAULT} ..."
446     # do not esacpe ${route} or it breaks!
447     route "${method}" ${route}
448     evaluate_retval
449     done
450     fi
451  }  }
452    
453  networking_start()  networking_start()
454  {  {
455   local iface dns   local iface dns routes ALL_INTERFACES
456    
457     if [[ -z $1 ]]
458     then
459     ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*)
460     else
461     if [[ -e ${rc_network_settings}/net.$1 ]]
462     then
463     ALL_INTERFACES="$1"
464     else
465     ${FAILURE}
466     rc_echo "Interface $1 does not exist. Aborting"
467     ${NORMAL}
468     exit 1
469     fi
470     fi
471    
472   # get list of all devices   # get list of all devices
473   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in ${ALL_INTERFACES}
474   do   do
475   # checkconfig   # checkconfig
476   source ${network_settings}/net.${iface} || exit 1   source ${rc_network_settings}/net.${iface} || exit 1
477   checkconfig   checkconfig
478    
479   echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."   # wait until the device is created
480     wait_online 5 "${iface}" || { rc_echo "device '${iface}' does not exist"; continue; }
481    
482   # setup mac   # setup mac
483   [ -n "${FORCE_MAC_TO}" ] && ifconfig ${iface} hw ether "${FORCE_MAC_TO}"   if [[ -n ${FORCE_MAC_TO} ]]
484     then
485     rc_print "Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... "
486     ifconfig "${iface}" hw ether "${FORCE_MAC_TO}"
487     evaluate_retval
488     fi
489    
490     # setup bridges
491     if [[ ${iface} = br[0-9]* ]]
492     then
493     config_bridge_devices "${iface}" add
494     fi
495    
496     # now configure wireless_extensions
497     [ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}"
498    
499     rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."
500    
501     # activate the interface
502     ifconfig "${iface}" up
503    
504   # setup static or dhcp   # setup static or dhcp
505   case ${NETWORKING} in   case ${NETWORKING} in
506   dhcp|DHCP)   dhcp|DHCP)
507   ${CURS_UP}   ${CURS_UP}
508   ${SET_WWCOL}   ${SET_WWCOL}
509   echo "[DHCP]"   rc_echo "[DHCP]"
510   loadproc ${DHCP_PROG} ${DHCP_START}   loadproc ${DHCP_PROG} ${DHCP_START} "${iface}"
511   ;;   ;;
512   static|STATIC)   static|STATIC)
513   ${CURS_UP}   ${CURS_UP}
514   ${SET_WWCOL}   ${SET_WWCOL}
515   echo "[STATIC]"   rc_echo "[STATIC]"
516   ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}"   ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}"
517   evaluate_retval   evaluate_retval
518   ;;   ;;
# Line 256  networking_start() Line 521  networking_start()
521   # setup def gw   # setup def gw
522   if [[ -n ${GATEWAY} ]]   if [[ -n ${GATEWAY} ]]
523   then   then
524   echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..."   rc_print "Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..."
525   route add default gateway ${GATEWAY} metric 1 dev ${iface}   route add default gateway "${GATEWAY}" metric 1 dev "${iface}"
526   evaluate_retval   evaluate_retval
527    
528     unset GATEWAY
529   fi   fi
530    
531   # setup /etc/resolv.conf   # setup /etc/resolv.conf
532     # add given nameserver
533   if [[ -n ${NAMESERVER} ]]   if [[ -n ${NAMESERVER} ]]
534   then   then
535   echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..."   rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..."
536    
537   # whipe out the old one   # wipe out the old one
538   echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf   echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf
539     # include head
540     if [ -f /etc/resolv.conf.head ]
541     then
542     cat /etc/resolv.conf.head >> /etc/resolv.conf
543     else
544     echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf
545     fi
546    
547   for dns in ${NAMESERVER}   for dns in ${NAMESERVER}
548   do   do
549   echo "nameserver ${dns}" >> /etc/resolv.conf   echo "nameserver ${dns}" >> /etc/resolv.conf
550   done   done
  fi  
551    
552   # setup wlan extensions   # include tail
553   if [ -x /usr/sbin/iwconfig ]   if [ -f /etc/resolv.conf.tail ]
554   then   then
555   setup_wireless_extensions "${iface}"   cat /etc/resolv.conf.tail >> /etc/resolv.conf
556     else
557     echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf
558     fi
559    
560     unset NAMESERVER
561   fi   fi
562   done   done
563    
564     # setup user routes
565     config_routes add
566  }  }
567    
568  networking_stop()  networking_stop()
569  {  {
570     if [[ -z $1 ]]
571     then
572     ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*)
573     else
574     if [[ -e ${rc_network_settings}/net.$1 ]]
575     then
576     ALL_INTERFACES="$1"
577     else
578     ${FAILURE}
579     rc_echo "Interface $1 does not exist. Aborting"
580     ${NORMAL}
581     exit 1
582     fi
583     fi
584    
585   # get list of all devices   # get list of all devices
586   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in ${ALL_INTERFACES}
587   do   do
588   source ${network_settings}/net.${iface} || exit 1   source ${rc_network_settings}/net.${iface} || exit 1
589   checkconfig   checkconfig
590    
591   if [[ -n ${GATEWAY} ]]   if [[ -n ${GATEWAY} ]]
592   then   then
593   echo -e ${COLOREDSTAR}"Removing default gateway ..."   rc_print "Removing default gateway ..."
594   route del -net default   route del -net default
595   evaluate_retval   evaluate_retval
596   fi   fi
597    
598   echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..."   rc_print "Bringing down interface ${COLBLUE}${iface}${COLDEFAULT} ..."
599   ifconfig ${iface} down   ifconfig "${iface}" down
600   evaluate_retval   evaluate_retval
601    
602     # remove bridges
603     if [[ ${iface} = br[0-9]* ]]
604     then
605     config_bridge_devices "${iface}" remove
606     fi
607    
608   # shutdown dhcp-daemon   # shutdown dhcp-daemon
609   if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof ${DHCP_PROG}) ]]   if [[ ${NETWORKING} = dhcp ]] && [[ -n $(pidof $(basename ${DHCP_PROG})) ]]
610   then   then
611   echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."   rc_print "Stopping the dhcp-daemon ..."
612   ${CURS_UP}   ${CURS_UP}
613   ${SET_WWCOL}   ${SET_WWCOL}
614   echo "[$(basename ${DHCP_PROG})]"   rc_echo "[$(basename ${DHCP_PROG})]"
615   ${DHCP_PROG} ${DHCP_STOP}   if [[ -z ${DHCP_STOP} ]]
616   evaluate_retval   then
617     killproc ${DHCP_PROG}
618     evaluate_retval
619     else
620     ${DHCP_PROG} ${DHCP_STOP} "${iface}"
621     evaluate_retval
622     fi
623   fi   fi
624    
625   # shutdown wpa_supplicant daemon   # shutdown wpa_supplicant daemon
# Line 318  networking_stop() Line 628  networking_stop()
628   killall wpa_supplicant   killall wpa_supplicant
629   fi   fi
630   done   done
631    
632     # remove state dir
633     if [ -d /run/wpa_supplicant ]
634     then
635     rm -rf /run/wpa_supplicant
636     fi
637    
638     # delete user routes
639     config_routes del
640  }  }
641    
642  case $1 in  case $1 in
643   start)   start)
644   networking_start   networking_start $2
645   update_svcstatus $1   update_svcstatus $1
646   splash svc_started "$(basename $0)" 0   splash svc_started "$(basename $0)" 0
647   ;;   ;;
648    
649   stop)   stop)
650   networking_stop   networking_stop $2
651   update_svcstatus $1   update_svcstatus $1
652   splash svc_stopped "$(basename $0)" 0   splash svc_stopped "$(basename $0)" 0
653   ;;   ;;
# Line 340  case $1 in Line 659  case $1 in
659   ;;   ;;
660    
661   *)   *)
662   echo "Usage: $0 {start|stop|restart}"   rc_echo "Usage: $0 {start|stop|restart} [interface]"
663   exit 1   exit 1
664   ;;   ;;
665  esac  esac

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