Magellan Linux

Annotation of /alx-src/trunk/alx-config/init.d/network

Parent Directory Parent Directory | Revision Log Revision Log


Revision 217 - (hide annotations) (download)
Sat Mar 5 17:08:18 2005 UTC (19 years, 2 months ago) by niro
File size: 3608 byte(s)
test; not ready for public

1 niro 217 #!/bin/bash
2     # Begin $rc_base/init.d/network - Network Control Script
3    
4     # Based on ethnet script from LFS-3.1 and earlier.
5     # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
6    
7     source /etc/sysconfig/rc
8     source $rc_functions
9     #source /etc/sysconfig/network
10    
11    
12     checkconfig() {
13     if [ -z $NETWORKING ]
14     then
15     echo "NETWORKING missing in net.${interface}, aborted"
16     exit 1
17     fi
18    
19     case $NETWORKING in
20     static)
21     if [ -z $IP ]
22     then
23     echo "IP missing in net.${interface}, aborted"
24     exit 1
25     fi
26    
27     if [ -z $NETMASK ]
28     then
29     echo -n "NETMASK missing in net.${interface}, "
30     echo "using 255.255.255.0"
31     NETMASK=255.255.255.0
32     fi
33    
34     if [ -z $BROADCAST ]
35     then
36     echo -n "BROADCAST missing in net.${interface}, "
37     echo "using default address"
38     fi
39     ;;
40     dhcp)
41     if [ -z $DHCP_PROG ]
42     then
43     echo "DHCP_PROG missing in net.${interface}, aborted"
44     exit 1
45     fi
46     ;;
47     esac
48     }
49    
50    
51    
52     case "$1" in
53     start)
54     #get network state from system, load networking or not ?
55     unset NO_NETWORK #to be safe :)
56    
57     if [ -f /var/state/network ]
58     then
59     source /var/state/network
60     if [ "${SYSTEM_NO_NETWORK}" == "true" ]
61     then
62     echo -e ${COLYELLOW}"Networking is disabled system-wide."${COLDEFAULT}
63     echo " Delete '/var/state/network' to enable networking."
64    
65     #and exit this script
66     exit 0
67     fi
68     fi
69    
70     progressbar 75
71     for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*)
72     do
73     interface=$(basename $file | sed s/net.//)
74     case "$interface" in
75     *~) ;;
76     *)
77     #$network_devices/ifup $interface
78     source $network_settings/net.${interface} || exit 1
79     checkconfig
80     case $NETWORKING in
81     dhcp)
82     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
83     $CURS_UP
84     $SET_WWCOL
85     echo "[DHCP]"
86     #modprobe $interface
87     loadproc $DHCP_PROG $DHCP_START
88     ;;
89     static)
90     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
91     $CURS_UP
92     $SET_WWCOL
93     echo "[STATIC]"
94     ifconfig $interface $IP netmask $NETMASK broadcast $BROADCAST
95     evaluate_retval
96     ;;
97     esac
98     ;;
99     esac
100     done
101    
102     if [ "$GATEWAY" != "" ]
103     then
104     echo -e ${COLOREDSTAR}"Setting up default gateway ..."
105     route add default gateway $GATEWAY metric 1 \
106     dev $GATEWAY_IF
107     evaluate_retval
108     fi
109     ;;
110    
111     stop)
112     progressbar 80
113     if [ "$GATEWAY" != "" ]
114     then
115     echo -e ${COLOREDSTAR}"Removing default gateway ..."
116     route del -net default
117     evaluate_retval
118     fi
119    
120     for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*)
121     do
122     interface=$(basename $file | sed s/net.//)
123     case "$interface" in
124     *~) ;;
125     *)
126     #$network_devices/ifdown $interface
127     source $network_settings/net.${interface} || exit 1
128     checkconfig
129     echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."
130     ifconfig eth0 down
131     evaluate_retval
132    
133     #shutdown dhcp-daemon
134     if [ $NETWORKING == dhcp ]
135     then
136     my_runlevel="`runlevel | cut -d ' ' -f2`"
137     if [ "$my_runlevel" -ne "0" -a "$my_runlevel" -ne "6" -a -n "$(pidof ${DHCP_PROG})" ]
138     then
139     echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."
140     $CURS_UP
141     $SET_WWCOL
142     echo "[${DHCP_PROG}]"
143     $DHCP_PROG $DHCP_STOP
144     evaluate_retval
145     fi
146     fi
147     ;;
148     esac
149     done
150    
151     #delete network state file if exist
152     [ -f /var/state/network ] && rm /var/state/network
153     ;;
154    
155     restart)
156     $0 stop
157     sleep 1
158     $0 start
159     ;;
160    
161     *)
162     echo "Usage: $0 {start|stop|restart}"
163     exit 1
164     ;;
165     esac
166    
167     # End /etc/rc.d/init.d/network

Properties

Name Value
svn:executable *