slitaz-vz view base-scripts/rc.network @ rev 2

Add stuff for templates
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Tue Nov 01 09:23:49 2011 +0100 (2011-11-01)
parents
children
line source
1 #!/bin/sh
2 # rc.network, set network config stuff for OpenVZ container.
3 #
4 #
6 . /etc/init.d/rc.functions
8 if [ -z "$2" ]; then
9 . /etc/network.conf
10 else
11 . $2
12 fi
14 Boot() {
15 # Set hostname.
16 /bin/hostname -F /etc/hostname
18 # We are always start loopback
19 ifconfig lo up
20 }
22 _ifconfig() {
23 # Use ethernet
24 ifconfig $INTERFACE up
26 # Start all network devices
27 for interface in /etc/network/ifconfig-*
28 do
29 DEVICE=$(echo "`basename $interface`" | sed 's/ifconfig-//')
30 . $interface
31 if [ "$ONBOOT" = "yes" ]; then
32 case $MODE in
33 static)
34 /sbin/ifconfig $DEVICE $IP netmask $NETMASK broadcast $BROADCAST up ;;
35 dhcp)
36 /sbin/udhcpc -b -T 1 -A 12 -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid ;;
37 *)
38 echo "$MODE is not supported." ;;
39 esac
40 fi
41 done
42 }
44 # Stopping everything
45 Stop() {
46 echo "Stopping all interfaces"
47 ifconfig $INTERFACE down
49 # Stopping all network interfaces.
50 for interface in /etc/network/ifconfig-*
51 do
52 DEVICE=$(echo "`basename $interface`" | sed 's/ifconfig-//')
53 . $interface
54 if [ "$ONBOOT" = "yes" ]; then
55 /sbin/ifconfig $DEVICE down
56 fi
57 done
59 }
61 Start() {
62 _ifconfig
63 }
65 # looking for arguments:
66 case $1 in
67 start)
68 Start ;;
69 stop)
70 Stop ;;
71 restart)
72 Stop
73 Start
74 ;;
75 *)
76 Boot
77 Start
78 ;;
79 esac