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

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