Magellan Linux

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

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: 3765 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     #aka_fix
89     route del default gw 128.20.50.13 &> /dev/null
90     sleep 1
91     route add default gw 128.20.50.21 &> /dev/null
92     ##########
93     ;;
94     static)
95     echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..."
96     $CURS_UP
97     $SET_WWCOL
98     echo "[STATIC]"
99     ifconfig $interface $IP netmask $NETMASK broadcast $BROADCAST
100     evaluate_retval
101     ;;
102     esac
103     ;;
104     esac
105     done
106    
107     if [ "$GATEWAY" != "" ]
108     then
109     echo -e ${COLOREDSTAR}"Setting up default gateway ..."
110     route add default gateway $GATEWAY metric 1 \
111     dev $GATEWAY_IF
112     evaluate_retval
113     fi
114     ;;
115    
116     stop)
117     progressbar 80
118     if [ "$GATEWAY" != "" ]
119     then
120     echo -e ${COLOREDSTAR}"Removing default gateway ..."
121     route del -net default
122     evaluate_retval
123     fi
124    
125     for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*)
126     do
127     interface=$(basename $file | sed s/net.//)
128     case "$interface" in
129     *~) ;;
130     *)
131     #$network_devices/ifdown $interface
132     source $network_settings/net.${interface} || exit 1
133     checkconfig
134     echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..."
135     ifconfig eth0 down
136     evaluate_retval
137    
138     #shutdown dhcp-daemon
139     if [ $NETWORKING == dhcp ]
140     then
141     my_runlevel="`runlevel | cut -d ' ' -f2`"
142     if [ "$my_runlevel" -ne "0" -a "$my_runlevel" -ne "6" -a -n "$(pidof ${DHCP_PROG})" ]
143     then
144     echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..."
145     $CURS_UP
146     $SET_WWCOL
147     echo "[${DHCP_PROG}]"
148     $DHCP_PROG $DHCP_STOP
149     evaluate_retval
150     fi
151     fi
152     ;;
153     esac
154     done
155    
156     #delete network state file if exist
157     [ -f /var/state/network ] && rm /var/state/network
158     ;;
159    
160     restart)
161     $0 stop
162     sleep 1
163     $0 start
164     ;;
165    
166     *)
167     echo "Usage: $0 {start|stop|restart}"
168     exit 1
169     ;;
170     esac
171    
172     # End /etc/rc.d/init.d/network

Properties

Name Value
svn:executable *