Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations) (download)
Tue Mar 15 19:07:56 2005 UTC (19 years, 2 months ago) by niro
File size: 3200 byte(s)
updated header and fixed whitespaces

1 #!/bin/bash
2 # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.3 2005-03-15 19:07:56 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 case "${NETWORKING}" in
68 dhcp)
69 echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
70 ${CURS_UP}
71 ${SET_WWCOL}
72 echo "[DHCP]"
73 loadproc ${DHCP_PROG} ${DHCP_START}
74 ;;
75 static)
76 echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
77 ${CURS_UP}
78 ${SET_WWCOL}
79 echo "[STATIC]"
80 ifconfig ${interface} ${IP} netmask ${NETMASK} broadcast ${BROADCAST}
81 evaluate_retval
82 ;;
83 esac
84 ;;
85 esac
86 done
87
88 if [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ]
89 then
90 echo -e ${COLOREDSTAR}"Setting up default gateway ..."
91 route add default gateway ${GATEWAY} metric 1 \
92 dev ${GATEWAY_IF}
93 evaluate_retval
94 fi
95
96 update_svcstatus $1
97 splash svc_started "$(basename $0)" 0
98 ;;
99
100 stop)
101 if [ -n "${GATEWAY}" ]
102 then
103 echo -e ${COLOREDSTAR}"Removing default gateway ..."
104 route del -net default
105 evaluate_retval
106 fi
107
108 for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*)
109 do
110 interface=$(basename ${file} | sed s/net.//)
111 case "${interface}" in
112 *~) ;;
113 *)
114 #$network_devices/ifdown $interface
115 source ${network_settings}/net.${interface} || exit 1
116 checkconfig
117 echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."
118 ifconfig ${interface} down
119 evaluate_retval
120
121 #shutdown dhcp-daemon
122 if [ "${NETWORKING}" == dhcp ]
123 then
124 my_runlevel="`runlevel | cut -d ' ' -f2`"
125 if [ -n "$(pidof ${DHCP_PROG})" ]
126 then
127 echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."
128 ${CURS_UP}
129 ${SET_WWCOL}
130 echo "[$(basename ${DHCP_PROG})]"
131 ${DHCP_PROG} ${DHCP_STOP}
132 evaluate_retval
133 fi
134 fi
135 ;;
136 esac
137 done
138
139 update_svcstatus $1
140 splash svc_stopped "$(basename $0)" 0
141 ;;
142
143 restart)
144 $0 stop
145 sleep 1
146 $0 start
147 ;;
148
149 *)
150 echo "Usage: $0 {start|stop|restart}"
151 exit 1
152 ;;
153 esac

Properties

Name Value
svn:executable *