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

Legend:
Removed from v.522  
changed lines
  Added in v.2911