slitaz-vz view base-scripts/vzconf.sh @ rev 5

Tiny edits
author Paul Issott <paul@slitaz.org>
date Mon Mar 26 21:42:12 2012 +0100 (2012-03-26)
parents 2d20f72ffb19
children
line source
1 #!/bin/sh
2 # Set network bridge for OpenVZ server
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 # MA 02110-1301, USA.
18 #
19 # 20011 - Eric Joseph-Alexandre <erjo@slitaz.org>
22 CONFIG_DIR=/var/lib/slitaz-vz
24 # Get real network device name from stored config if exists.
25 if [ -f $CONFIG_DIR/network/interfaces ]; then
26 BRIDGE=$(grep ^BRIDGE $CONFIG_DIR/network/interfaces | sed 's/.*"\(.*\)"/\1/')
27 IFACE=$(grep ^INTERFACE $CONFIG_DIR/network/interfaces | sed 's/.*"\(.*\)"/\1/')
28 else
29 BRIDGE=br0
30 IFACE=$(grep ^INTERFACE /etc/network.conf | sed 's/.*"\(.*\)"/\1/')
32 # Store interface info for the next boot in hd mode
33 mkdir -p $CONFIG_DIR/network
34 echo "BRIDGE=\"$BRIDGE\"" > $CONFIG_DIR/network/interfaces
35 echo "INTERFACE=\"$IFACE\"" >> $CONFIG_DIR/network/interfaces
36 fi
38 # Set Bridge configuration
39 if [ -x /usr/sbin/brctl ]; then
40 if (/usr/sbin/brctl addbr $BRIDGE); then
41 /sbin/ifconfig $IFACE down
42 /sbin/ifconfig $IFACE 0
43 /usr/sbin/brctl addif $BRIDGE $IFACE
45 # Update INTERFACE in /etc/network.conf
46 grep ^INTERFACE /etc/network.conf | grep -q $BRIDGE \
47 || sed -i "s/^INTERFACE=\"\(.*\)\"/INTERFACE=\"$BRIDGE\"/" /etc/network.conf
48 else
49 echo "Unable to set netwok bridge"
50 fi
51 else
52 echo "Can't find brctl. Make sure you have installed brctl-utils"
53 fi