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

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