Magellan Linux

Annotation of /trunk/initscripts/sysvinit/rc/network

Parent Directory Parent Directory | Revision Log Revision Log


Revision 181 - (hide annotations) (download)
Wed Aug 3 17:54:05 2005 UTC (18 years, 9 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/network
File size: 3321 byte(s)
added mac fake support

1 niro 2 #!/bin/bash
2 niro 181 # $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 niro 2
4     #%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k
5     #%start: 20
6     #%stop: 80
7    
8     #deps
9     #%needs:
10     #%before:
11     #%after:
12    
13     source /etc/sysconfig/rc
14 niro 20 source ${rc_functions}
15 niro 2
16     checkconfig() {
17 niro 20 if [ -z "${NETWORKING}" ]
18 niro 2 then
19     echo "NETWORKING missing in net.${interface}, aborted"
20     exit 1
21     fi
22    
23 niro 20 case "${NETWORKING}" in
24 niro 2 static)
25 niro 20 if [ -z "${IP}" ]
26 niro 2 then
27     echo "IP missing in net.${interface}, aborted"
28     exit 1
29     fi
30    
31 niro 20 if [ -z "${NETMASK}" ]
32 niro 2 then
33     echo -n "NETMASK missing in net.${interface}, "
34     echo "using 255.255.255.0"
35     NETMASK=255.255.255.0
36     fi
37    
38 niro 20 if [ -z "${BROADCAST}" ]
39 niro 2 then
40     echo -n "BROADCAST missing in net.${interface}, "
41     echo "using default address"
42     fi
43     ;;
44 niro 20
45 niro 2 dhcp)
46 niro 20 if [ -z "${DHCP_PROG}" ]
47 niro 2 then
48     echo "DHCP_PROG missing in net.${interface}, aborted"
49     exit 1
50     fi
51     ;;
52 niro 20
53 niro 2 esac
54     }
55    
56    
57     case "$1" in
58     start)
59 niro 20 for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*)
60 niro 2 do
61 niro 20 interface=$(basename ${file} | sed s/net.//)
62     case "${interface}" in
63 niro 2 *~) ;;
64     *)
65 niro 20 source ${network_settings}/net.${interface} || exit 1
66 niro 2 checkconfig
67 niro 181
68     # first set mac address forcing
69     [ -n "${FORCE_MAC_TO}" ] && ifconfig ${interface} hw ether "${FORCE_MAC_TO}"
70    
71 niro 20 case "${NETWORKING}" in
72 niro 2 dhcp)
73     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
74 niro 20 ${CURS_UP}
75     ${SET_WWCOL}
76 niro 2 echo "[DHCP]"
77 niro 20 loadproc ${DHCP_PROG} ${DHCP_START}
78 niro 2 ;;
79     static)
80     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
81 niro 20 ${CURS_UP}
82     ${SET_WWCOL}
83 niro 2 echo "[STATIC]"
84 niro 20 ifconfig ${interface} ${IP} netmask ${NETMASK} broadcast ${BROADCAST}
85 niro 2 evaluate_retval
86     ;;
87     esac
88     ;;
89     esac
90     done
91    
92 niro 20 if [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ]
93 niro 2 then
94     echo -e ${COLOREDSTAR}"Setting up default gateway ..."
95 niro 20 route add default gateway ${GATEWAY} metric 1 \
96     dev ${GATEWAY_IF}
97 niro 2 evaluate_retval
98     fi
99    
100     update_svcstatus $1
101     splash svc_started "$(basename $0)" 0
102     ;;
103    
104     stop)
105 niro 20 if [ -n "${GATEWAY}" ]
106 niro 2 then
107     echo -e ${COLOREDSTAR}"Removing default gateway ..."
108     route del -net default
109     evaluate_retval
110     fi
111    
112 niro 20 for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*)
113 niro 2 do
114 niro 20 interface=$(basename ${file} | sed s/net.//)
115     case "${interface}" in
116 niro 2 *~) ;;
117     *)
118     #$network_devices/ifdown $interface
119 niro 20 source ${network_settings}/net.${interface} || exit 1
120 niro 2 checkconfig
121     echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."
122 niro 20 ifconfig ${interface} down
123 niro 2 evaluate_retval
124    
125     #shutdown dhcp-daemon
126 niro 20 if [ "${NETWORKING}" == dhcp ]
127 niro 2 then
128     my_runlevel="`runlevel | cut -d ' ' -f2`"
129 niro 20 if [ -n "$(pidof ${DHCP_PROG})" ]
130 niro 2 then
131     echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."
132 niro 20 ${CURS_UP}
133     ${SET_WWCOL}
134     echo "[$(basename ${DHCP_PROG})]"
135     ${DHCP_PROG} ${DHCP_STOP}
136 niro 2 evaluate_retval
137     fi
138     fi
139     ;;
140     esac
141     done
142    
143     update_svcstatus $1
144     splash svc_stopped "$(basename $0)" 0
145     ;;
146    
147     restart)
148     $0 stop
149     sleep 1
150     $0 start
151     ;;
152    
153     *)
154     echo "Usage: $0 {start|stop|restart}"
155     exit 1
156     ;;
157     esac

Properties

Name Value
svn:executable *