slitaz-vz diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/base-scripts/rc.network Tue Nov 01 09:23:49 2011 +0100 1.3 @@ -0,0 +1,79 @@ 1.4 +#!/bin/sh 1.5 +# rc.network, set network config stuff for OpenVZ container. 1.6 +# 1.7 +# 1.8 + 1.9 +. /etc/init.d/rc.functions 1.10 + 1.11 +if [ -z "$2" ]; then 1.12 + . /etc/network.conf 1.13 +else 1.14 + . $2 1.15 +fi 1.16 + 1.17 +Boot() { 1.18 + # Set hostname. 1.19 + /bin/hostname -F /etc/hostname 1.20 + 1.21 + # We are always start loopback 1.22 + ifconfig lo up 1.23 +} 1.24 + 1.25 +_ifconfig() { 1.26 + # Use ethernet 1.27 + ifconfig $INTERFACE up 1.28 + 1.29 + # Start all network devices 1.30 + for interface in /etc/network/ifconfig-* 1.31 + do 1.32 + DEVICE=$(echo "`basename $interface`" | sed 's/ifconfig-//') 1.33 + . $interface 1.34 + if [ "$ONBOOT" = "yes" ]; then 1.35 + case $MODE in 1.36 + static) 1.37 + /sbin/ifconfig $DEVICE $IP netmask $NETMASK broadcast $BROADCAST up ;; 1.38 + dhcp) 1.39 + /sbin/udhcpc -b -T 1 -A 12 -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid ;; 1.40 + *) 1.41 + echo "$MODE is not supported." ;; 1.42 + esac 1.43 + fi 1.44 + done 1.45 +} 1.46 + 1.47 +# Stopping everything 1.48 +Stop() { 1.49 + echo "Stopping all interfaces" 1.50 + ifconfig $INTERFACE down 1.51 + 1.52 + # Stopping all network interfaces. 1.53 + for interface in /etc/network/ifconfig-* 1.54 + do 1.55 + DEVICE=$(echo "`basename $interface`" | sed 's/ifconfig-//') 1.56 + . $interface 1.57 + if [ "$ONBOOT" = "yes" ]; then 1.58 + /sbin/ifconfig $DEVICE down 1.59 + fi 1.60 + done 1.61 + 1.62 +} 1.63 + 1.64 +Start() { 1.65 + _ifconfig 1.66 +} 1.67 + 1.68 +# looking for arguments: 1.69 +case $1 in 1.70 + start) 1.71 + Start ;; 1.72 + stop) 1.73 + Stop ;; 1.74 + restart) 1.75 + Stop 1.76 + Start 1.77 + ;; 1.78 + *) 1.79 + Boot 1.80 + Start 1.81 + ;; 1.82 +esac