Magellan Linux

Diff of /trunk/magellan-initscripts/etc/rc.d/init.d/network

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

revision 522 by niro, Sat Aug 18 18:44:15 2007 UTC revision 691 by niro, Sat Mar 22 17:54:46 2008 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 $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.18 2008-03-22 17:54:46 niro Exp $
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 24  read_value() Line 24  read_value()
24   # global   # global
25   local ONBOOT   local ONBOOT
26   local NETWORKING   local NETWORKING
27    
28   # static   # static
29   local IP   local IP
30   local NETMASK   local NETMASK
# Line 60  read_value() Line 60  read_value()
60   local WIRELESS_NICK   local WIRELESS_NICK
61   local WIRELESS_NWID   local WIRELESS_NWID
62   local WIRELESS_POWER   local WIRELESS_POWER
63     local WIRELESS_WPA_DRIVER
64    
65     local BRIDGE_INTERFACES
66     local BRIDGE_STP
67    
68   source ${file}   source ${file}
69   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
# Line 68  read_value() Line 72  read_value()
72    
73  checkconfig()  checkconfig()
74  {  {
75   if [ -z "${NETWORKING}" ]   if [[ -z ${NETWORKING} ]]
76   then   then
77   echo "NETWORKING missing in net.${interface}, aborted"   echo "NETWORKING missing in net.${interface}, aborted"
78   exit 1   exit 1
# Line 76  checkconfig() Line 80  checkconfig()
80    
81   case "${NETWORKING}" in   case "${NETWORKING}" in
82   static)   static)
83   if [ -z "${IP}" ]   if [[ -z ${IP} ]]
84   then   then
85   echo "IP missing in net.${interface}, aborted"   echo "IP missing in net.${interface}, aborted"
86   exit 1   exit 1
87   fi   fi
88    
89   if [ -z "${NETMASK}" ]   if [[ -z ${NETMASK} ]]
90   then   then
91   echo -n "NETMASK missing in net.${interface}, "   echo -n "NETMASK missing in net.${interface}, "
92   echo "using 255.255.255.0"   echo "using 255.255.255.0"
93   NETMASK=255.255.255.0   NETMASK=255.255.255.0
94   fi   fi
95    
96   if [ -z "${BROADCAST}" ]   if [[ -z ${BROADCAST} ]]
97   then   then
98   echo -n "BROADCAST missing in net.${interface}, "   echo -n "BROADCAST missing in net.${interface}, "
99   echo "using default address"   echo "using default address"
# Line 97  checkconfig() Line 101  checkconfig()
101   ;;   ;;
102    
103   dhcp)   dhcp)
104   if [ -z "${DHCP_PROG}" ]   if [[ -z ${DHCP_PROG} ]]
105   then   then
106   echo "DHCP_PROG missing in net.${interface}, aborted"   echo "DHCP_PROG missing in net.${interface}, aborted"
107   exit 1   exit 1
# Line 251  config_bridge_devices() Line 255  config_bridge_devices()
255  {  {
256   local iface="$1"   local iface="$1"
257   local method="$2"   local method="$2"
258     local bport
259    
260   if [[ -z ${iface} ]]   if [[ -z ${iface} ]]
261   then   then
# Line 272  config_bridge_devices() Line 277  config_bridge_devices()
277   fi   fi
278    
279   # check the config   # check the config
280   if [[ -z ${BRIDGE_INTERFACE} ]]   if [[ -z ${BRIDGE_INTERFACES} ]]
281   then   then
282   echo "BRIDGE: no \$BRIDGE_INTERFACE given. Aborting setup."   echo "BRIDGE: no \$BRIDGE_INTERFACES given. Aborting setup."
283   return 1   return 1
284   fi   fi
285    
# Line 282  config_bridge_devices() Line 287  config_bridge_devices()
287   add)   add)
288   # setup the bridge device   # setup the bridge device
289   brctl addbr ${iface}   brctl addbr ${iface}
290   # enter promiscous mode   for bport in ${BRIDGE_INTERFACES}
291   ifconfig ${BRIDGE_INTERFACE} 0.0.0.0 promisc   do
292   # now setup the bridge   # enter promiscous mode
293   brctl addif ${iface} ${BRIDGE_INTERFACE}   ifconfig ${bport} 0.0.0.0 promisc
294     # now setup the bridge
295     brctl addif ${iface} ${bport}
296     done
297     # enable spanning-tree protocol
298     case ${BRIDGE_STP} in
299     on|off) brctl stp ${iface} ${BRIDGE_STP} ;;
300     *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;;
301     esac
302   ;;   ;;
303    
304   remove)   remove)
305   # bring the interface down   for bport in ${BRIDGE_INTERFACE}
306   ifconfig ${BRIDGE_INTERFACE} down   do
307   # remove the interface from the bridge   # bring the interface down
308   brctl delif ${iface} ${BRIDGE_INTERFACE}   ifconfig ${bport} down
309     # remove the interface from the bridge
310     brctl delif ${iface} ${bport}
311     done
312   # bring the bridge down   # bring the bridge down
313   brctl delbr ${iface}   brctl delbr ${iface}
314   ;;   ;;
315   esac   esac
316    
317   # unset the bridge variable to be safe   # unset the bridge variable to be safe
318   unset BRIDGE_INTERFACE   unset BRIDGE_INTERFACES
319   # continue to setup generic networking   # continue to setup generic networking
320  }  }
321    
# Line 404  networking_start() Line 421  networking_start()
421   echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..."   echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..."
422   route add default gateway ${GATEWAY} metric 1 dev ${iface}   route add default gateway ${GATEWAY} metric 1 dev ${iface}
423   evaluate_retval   evaluate_retval
424    
425     unset GATEWAY
426   fi   fi
427    
428   # setup /etc/resolv.conf   # setup /etc/resolv.conf
# Line 417  networking_start() Line 436  networking_start()
436   do   do
437   echo "nameserver ${dns}" >> /etc/resolv.conf   echo "nameserver ${dns}" >> /etc/resolv.conf
438   done   done
439    
440     unset NAMESERVER
441   fi   fi
442   done   done
443    

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