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 638 by niro, Thu Dec 13 12:18:23 2007 UTC trunk/initscripts/sysvinit/rc/network revision 2031 by niro, Thu Jan 24 14:33:31 2013 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.15 2007-12-13 12:18:23 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 64  read_value() Line 65  read_value()
65    
66   local BRIDGE_INTERFACES   local BRIDGE_INTERFACES
67   local BRIDGE_STP   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 74  checkconfig() Line 82  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    
# Line 82  checkconfig() Line 90  checkconfig()
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 121  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 and exclude net.routes too  
  case "${iface}" in  
  *~) ;;  
  */net.routes) ;;  
  *) devices="${devices} $(basename ${file} | sed s/net.//)" ;;  
  esac  
147   fi   fi
148   done   done
149    
# Line 142  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 162  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
195    
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/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 195  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   # remove old state dir
224   [ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant   [ -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 \
# Line 212  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 222  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    
# Line 234  setup_wireless_extensions() Line 253  setup_wireless_extensions()
253   [[ -n ${WIRELESS_NICK} ]] ||   [[ -n ${WIRELESS_NICK} ]] ||
254   [[ -n ${WIRELESS_AUTH_MODE} ]]   [[ -n ${WIRELESS_AUTH_MODE} ]]
255   then   then
256   echo -e ${COLOREDSTAR}"Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... "   rc_print "Setting up wlan-ext for ${COLBLUE}${iface}${COLDEFAULT} ... "
257   fi   fi
258    
259   [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"   [[ -n ${WIRELESS_BITRATE} ]] && iwconfig "${iface}" rate "${WIRELESS_BITRATE}"
# Line 245  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   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()  config_bridge_devices()
# Line 259  config_bridge_devices() Line 345  config_bridge_devices()
345    
346   if [[ -z ${iface} ]]   if [[ -z ${iface} ]]
347   then   then
348   echo "BRIDGE: no \$iface given. Aborting setup."   rc_echo "BRIDGE: no \$iface given. Aborting setup."
349   return 1   return 1
350   fi   fi
351    
352   if [[ -z ${method} ]]   if [[ -z ${method} ]]
353   then   then
354   echo "BRIDGE: no \$method given. Aborting setup."   rc_echo "BRIDGE: no \$method given. Aborting setup."
355   return 1   return 1
356   fi   fi
357    
358   # first check for brctl   # first check for brctl
359   if [[ -z $(which brctl) ]]   if [[ -z $(type -P brctl) ]]
360   then   then
361   echo "brctl not found! Please install 'net-misc/bridge-utils'."   rc_echo "brctl not found! Please install 'net-misc/bridge-utils'."
362   return 1   return 1
363   fi   fi
364    
365   # check the config   # check the config
366   if [[ -z ${BRIDGE_INTERFACES} ]]   if [[ -z ${BRIDGE_INTERFACES} ]]
367   then   then
368   echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup."   rc_echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup."
369   return 1   return 1
370   fi   fi
371    
372   case ${method} in   case ${method} in
373   add)   add)
374   # setup the bridge device   # setup the bridge device
375   brctl addbr ${iface}   brctl addbr "${iface}"
376   for bport in ${BRIDGE_INTERFACES}   for bport in ${BRIDGE_INTERFACES}
377   do   do
378   # enter promiscous mode   # enter promiscous mode
379   ifconfig ${bport} 0.0.0.0 promisc   ifconfig "${bport}" 0.0.0.0 promisc
380   # now setup the bridge   # now setup the bridge
381   brctl addif ${iface} ${bport}   brctl addif "${iface}" "${bport}"
382   done   done
383   # enable spanning-tree protocol   # configure all other options
384   case BRIDGE_STP in   config_bridge_options "${iface}"
  on|off) brctl stp ${iface} ${BRIDGE_STP} ;;  
  *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;;  
  esac  
385   ;;   ;;
386    
387   remove)   remove)
388   for bport in ${BRIDGE_INTERFACE}   for bport in ${BRIDGE_INTERFACE}
389   do   do
390   # bring the interface down   # bring the interface down
391   ifconfig ${bport} down   ifconfig "${bport}" down
392   # remove the interface from the bridge   # remove the interface from the bridge
393   brctl delif ${iface} ${bport}   brctl delif "${iface}" "${bport}"
394   done   done
395   # bring the bridge down   # bring the bridge down
396   brctl delbr ${iface}   brctl delbr "${iface}"
397   ;;   ;;
398   esac   esac
399    
# Line 326  config_routes() Line 409  config_routes()
409    
410   # only add and del are allowed   # only add and del are allowed
411   case ${method} in   case ${method} in
412   add) message="Adding route ${COLBLUE}${route}${COLDEFAULT} ..." ;;   add) message="Adding" ;;
413   del) message="Removing route ${COLBLUE}${route}${COLDEFAULT} ..." ;;   del) message="Removing" ;;
414   *)   *)
415   echo "config_routes: unsupported \$method '${method}'."   rc_echo "config_routes: unsupported \$method '${method}'."
416   exit 1   exit 1
417   ;;   ;;
418   esac   esac
# Line 343  config_routes() Line 426  config_routes()
426   case "${route}" in   case "${route}" in
427   \#*|"") continue ;;   \#*|"") continue ;;
428   esac   esac
429   echo -e ${COLOREDSTAR}"${message}"   rc_print "${message} route ${COLBLUE}${route}${COLDEFAULT} ..."
430   route ${method} ${route}   # do not esacpe ${route} or it breaks!
431     route "${method}" ${route}
432   evaluate_retval   evaluate_retval
433   done   done
434   fi   fi
# Line 356  networking_start() Line 440  networking_start()
440    
441   if [[ -z $1 ]]   if [[ -z $1 ]]
442   then   then
443   ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*)   ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*)
444   else   else
445   if [[ -e ${network_settings}/net.$1 ]]   if [[ -e ${rc_network_settings}/net.$1 ]]
446   then   then
447   ALL_INTERFACES="$1"   ALL_INTERFACES="$1"
448   else   else
449   ${FAILURE}   ${FAILURE}
450   echo "Interface $1 does not exist. Aborting"   rc_echo "Interface $1 does not exist. Aborting"
451   ${NORMAL}   ${NORMAL}
452   exit 1   exit 1
453   fi   fi
# Line 373  networking_start() Line 457  networking_start()
457   for iface in ${ALL_INTERFACES}   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
# Line 387  networking_start() Line 471  networking_start()
471   # setup bridges   # setup bridges
472   if [[ ${iface} = br[0-9]* ]]   if [[ ${iface} = br[0-9]* ]]
473   then   then
474   config_bridge_devices ${iface} add   config_bridge_devices "${iface}" add
475   fi   fi
476    
  # activate the interface  
  ifconfig "${iface}" up  
   
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} "${iface}"   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 418  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    
# Line 445  networking_stop() Line 550  networking_stop()
550  {  {
551   if [[ -z $1 ]]   if [[ -z $1 ]]
552   then   then
553   ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*)   ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*)
554   else   else
555   if [[ -e ${network_settings}/net.$1 ]]   if [[ -e ${rc_network_settings}/net.$1 ]]
556   then   then
557   ALL_INTERFACES="$1"   ALL_INTERFACES="$1"
558   else   else
559   ${FAILURE}   ${FAILURE}
560   echo "Interface $1 does not exist. Aborting"   rc_echo "Interface $1 does not exist. Aborting"
561   ${NORMAL}   ${NORMAL}
562   exit 1   exit 1
563   fi   fi
# Line 461  networking_stop() Line 566  networking_stop()
566   # get list of all devices   # get list of all devices
567   for iface in ${ALL_INTERFACES}   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   # remove bridges
584   if [[ ${iface} = br[0-9]* ]]   if [[ ${iface} = br[0-9]* ]]
585   then   then
586   config_bridge_devices ${iface} remove   config_bridge_devices "${iface}" remove
587   fi   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 500  networking_stop() Line 611  networking_stop()
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   # delete user routes
# Line 529  case $1 in Line 640  case $1 in
640   ;;   ;;
641    
642   *)   *)
643   echo "Usage: $0 {start|stop|restart} [interface]"   rc_echo "Usage: $0 {start|stop|restart} [interface]"
644   exit 1   exit 1
645   ;;   ;;
646  esac  esac

Legend:
Removed from v.638  
changed lines
  Added in v.2031