Contents of /tags/init-0_7_0/sysvinit/rc/network
Parent Directory | Revision Log
Revision 181 -
(show annotations)
(download)
Wed Aug 3 17:54:05 2005 UTC (19 years, 1 month ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/network
File size: 3321 byte(s)
Wed Aug 3 17:54:05 2005 UTC (19 years, 1 month ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/network
File size: 3321 byte(s)
added mac fake support
1 | #!/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 |
5 | #%start: 20 |
6 | #%stop: 80 |
7 | |
8 | #deps |
9 | #%needs: |
10 | #%before: |
11 | #%after: |
12 | |
13 | source /etc/sysconfig/rc |
14 | source ${rc_functions} |
15 | |
16 | checkconfig() { |
17 | if [ -z "${NETWORKING}" ] |
18 | then |
19 | echo "NETWORKING missing in net.${interface}, aborted" |
20 | exit 1 |
21 | fi |
22 | |
23 | case "${NETWORKING}" in |
24 | static) |
25 | if [ -z "${IP}" ] |
26 | then |
27 | echo "IP missing in net.${interface}, aborted" |
28 | exit 1 |
29 | fi |
30 | |
31 | if [ -z "${NETMASK}" ] |
32 | 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 | if [ -z "${BROADCAST}" ] |
39 | then |
40 | echo -n "BROADCAST missing in net.${interface}, " |
41 | echo "using default address" |
42 | fi |
43 | ;; |
44 | |
45 | dhcp) |
46 | if [ -z "${DHCP_PROG}" ] |
47 | then |
48 | echo "DHCP_PROG missing in net.${interface}, aborted" |
49 | exit 1 |
50 | fi |
51 | ;; |
52 | |
53 | esac |
54 | } |
55 | |
56 | |
57 | case "$1" in |
58 | start) |
59 | for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*) |
60 | do |
61 | interface=$(basename ${file} | sed s/net.//) |
62 | case "${interface}" in |
63 | *~) ;; |
64 | *) |
65 | source ${network_settings}/net.${interface} || exit 1 |
66 | checkconfig |
67 | |
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) |
73 | echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." |
74 | ${CURS_UP} |
75 | ${SET_WWCOL} |
76 | echo "[DHCP]" |
77 | loadproc ${DHCP_PROG} ${DHCP_START} |
78 | ;; |
79 | static) |
80 | echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." |
81 | ${CURS_UP} |
82 | ${SET_WWCOL} |
83 | echo "[STATIC]" |
84 | ifconfig ${interface} ${IP} netmask ${NETMASK} broadcast ${BROADCAST} |
85 | evaluate_retval |
86 | ;; |
87 | esac |
88 | ;; |
89 | esac |
90 | done |
91 | |
92 | if [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ] |
93 | then |
94 | echo -e ${COLOREDSTAR}"Setting up default gateway ..." |
95 | route add default gateway ${GATEWAY} metric 1 \ |
96 | dev ${GATEWAY_IF} |
97 | evaluate_retval |
98 | fi |
99 | |
100 | update_svcstatus $1 |
101 | splash svc_started "$(basename $0)" 0 |
102 | ;; |
103 | |
104 | stop) |
105 | if [ -n "${GATEWAY}" ] |
106 | then |
107 | echo -e ${COLOREDSTAR}"Removing default gateway ..." |
108 | route del -net default |
109 | evaluate_retval |
110 | fi |
111 | |
112 | for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*) |
113 | do |
114 | interface=$(basename ${file} | sed s/net.//) |
115 | case "${interface}" in |
116 | *~) ;; |
117 | *) |
118 | #$network_devices/ifdown $interface |
119 | source ${network_settings}/net.${interface} || exit 1 |
120 | checkconfig |
121 | echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..." |
122 | ifconfig ${interface} down |
123 | evaluate_retval |
124 | |
125 | #shutdown dhcp-daemon |
126 | if [ "${NETWORKING}" == dhcp ] |
127 | then |
128 | my_runlevel="`runlevel | cut -d ' ' -f2`" |
129 | if [ -n "$(pidof ${DHCP_PROG})" ] |
130 | then |
131 | echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." |
132 | ${CURS_UP} |
133 | ${SET_WWCOL} |
134 | echo "[$(basename ${DHCP_PROG})]" |
135 | ${DHCP_PROG} ${DHCP_STOP} |
136 | 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 | * |