Magellan Linux

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

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

branches/unlabeled-1.1.1/magellan-initscripts/etc/rc.d/init.d/network revision 2 by niro, Mon Dec 13 22:52:07 2004 UTC trunk/magellan-initscripts/etc/rc.d/init.d/network revision 181 by niro, Wed Aug 3 17:54:05 2005 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.4 2005-08-03 17:54:05 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 10  Line 11 
11  #%after:  #%after:
12    
13  source /etc/sysconfig/rc  source /etc/sysconfig/rc
14  source $rc_functions  source ${rc_functions}
15    
16  checkconfig() {  checkconfig() {
17   if [ -z $NETWORKING ]   if [ -z "${NETWORKING}" ]
18   then   then
19   echo "NETWORKING missing in net.${interface}, aborted"   echo "NETWORKING missing in net.${interface}, aborted"
20   exit 1   exit 1
21   fi   fi
22    
23   case $NETWORKING in   case "${NETWORKING}" in
24   static)   static)
25   if [ -z $IP ]   if [ -z "${IP}" ]
26   then   then
27   echo "IP missing in net.${interface}, aborted"   echo "IP missing in net.${interface}, aborted"
28   exit 1   exit 1
29   fi   fi
30    
31   if [ -z $NETMASK ]   if [ -z "${NETMASK}" ]
32   then   then
33   echo -n "NETMASK missing in net.${interface}, "   echo -n "NETMASK missing in net.${interface}, "
34   echo "using 255.255.255.0"   echo "using 255.255.255.0"
35   NETMASK=255.255.255.0   NETMASK=255.255.255.0
36   fi   fi
37    
38   if [ -z $BROADCAST ]   if [ -z "${BROADCAST}" ]
39   then   then
40   echo -n "BROADCAST missing in net.${interface}, "   echo -n "BROADCAST missing in net.${interface}, "
41   echo "using default address"   echo "using default address"
42   fi   fi
43   ;;   ;;
44    
45   dhcp)   dhcp)
46   if [ -z $DHCP_PROG ]   if [ -z "${DHCP_PROG}" ]
47   then   then
48   echo "DHCP_PROG missing in net.${interface}, aborted"   echo "DHCP_PROG missing in net.${interface}, aborted"
49   exit 1   exit 1
50   fi   fi
51   ;;   ;;
52    
53   esac   esac
54  }  }
55    
56    
57  case "$1" in  case "$1" in
58   start)   start)
59   for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*)   for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*)
60   do   do
61   interface=$(basename $file | sed s/net.//)   interface=$(basename ${file} | sed s/net.//)
62   case "$interface" in   case "${interface}" in
63   *~) ;;   *~) ;;
64   *)   *)
65   #$network_devices/ifup $interface   source ${network_settings}/net.${interface} || exit 1
  source $network_settings/net.${interface} || exit 1  
66   checkconfig   checkconfig
67   case $NETWORKING in  
68     # first set mac address forcing
69     [ -n "${FORCE_MAC_TO}" ] && ifconfig ${interface} hw ether "${FORCE_MAC_TO}"
70    
71     case "${NETWORKING}" in
72   dhcp)   dhcp)
73   echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."   echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
74   $CURS_UP   ${CURS_UP}
75   $SET_WWCOL   ${SET_WWCOL}
76   echo "[DHCP]"   echo "[DHCP]"
77   #modprobe $interface   loadproc ${DHCP_PROG} ${DHCP_START}
  loadproc $DHCP_PROG $DHCP_START  
78   ;;   ;;
79   static)   static)
80   echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."   echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
81   $CURS_UP   ${CURS_UP}
82   $SET_WWCOL   ${SET_WWCOL}
83   echo "[STATIC]"   echo "[STATIC]"
84   ifconfig $interface $IP netmask $NETMASK broadcast $BROADCAST   ifconfig ${interface} ${IP} netmask ${NETMASK} broadcast ${BROADCAST}
85   evaluate_retval   evaluate_retval
86   ;;   ;;
87   esac   esac
# Line 84  case "$1" in Line 89  case "$1" in
89   esac   esac
90   done   done
91    
92   if [ "$GATEWAY" != "" ]   if [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ]
93   then   then
94   echo -e ${COLOREDSTAR}"Setting up default gateway ..."   echo -e ${COLOREDSTAR}"Setting up default gateway ..."
95   route add default gateway $GATEWAY metric 1 \   route add default gateway ${GATEWAY} metric 1 \
96   dev $GATEWAY_IF   dev ${GATEWAY_IF}
97   evaluate_retval   evaluate_retval
98   fi   fi
99    
# Line 97  case "$1" in Line 102  case "$1" in
102   ;;   ;;
103    
104   stop)   stop)
105   if [ "$GATEWAY" != "" ]   if [ -n "${GATEWAY}" ]
106   then   then
107   echo -e ${COLOREDSTAR}"Removing default gateway ..."   echo -e ${COLOREDSTAR}"Removing default gateway ..."
108   route del -net default   route del -net default
109   evaluate_retval   evaluate_retval
110   fi   fi
111    
112   for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*)   for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*)
113   do   do
114   interface=$(basename $file | sed s/net.//)   interface=$(basename ${file} | sed s/net.//)
115   case "$interface" in   case "${interface}" in
116   *~) ;;   *~) ;;
117   *)   *)
118   #$network_devices/ifdown $interface   #$network_devices/ifdown $interface
119   source $network_settings/net.${interface} || exit 1   source ${network_settings}/net.${interface} || exit 1
120   checkconfig   checkconfig
121   echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."   echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."
122   ifconfig eth0 down   ifconfig ${interface} down
123   evaluate_retval   evaluate_retval
124    
125   #shutdown dhcp-daemon   #shutdown dhcp-daemon
126   if [ $NETWORKING == dhcp ]   if [ "${NETWORKING}" == dhcp ]
127   then   then
128   my_runlevel="`runlevel | cut -d ' ' -f2`"   my_runlevel="`runlevel | cut -d ' ' -f2`"
129   if [ "$my_runlevel" -ne "0" -a "$my_runlevel" -ne "6" ]   if [ -n "$(pidof ${DHCP_PROG})" ]
130   then   then
131   echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."   echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."
132   $CURS_UP   ${CURS_UP}
133   $SET_WWCOL   ${SET_WWCOL}
134   echo "[${DHCP_PROG}]"   echo "[$(basename ${DHCP_PROG})]"
135   $DHCP_PROG $DHCP_STOP   ${DHCP_PROG} ${DHCP_STOP}
136   evaluate_retval   evaluate_retval
137   fi   fi
138   fi   fi

Legend:
Removed from v.2  
changed lines
  Added in v.181