slitaz-vz diff base-scripts/vzconf.sh @ 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 | 7ce131de8af6 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/base-scripts/vzconf.sh Tue Nov 01 09:23:49 2011 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +#!/bin/sh 1.5 +# Set network bridge for OpenVZ server 1.6 +# 1.7 +# This program is free software; you can redistribute it and/or modify 1.8 +# it under the terms of the GNU General Public License as published by 1.9 +# the Free Software Foundation; either version 2 of the License, or 1.10 +# (at your option) any later version. 1.11 +# 1.12 +# This program is distributed in the hope that it will be useful, 1.13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 1.14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.15 +# GNU General Public License for more details. 1.16 +# 1.17 +# You should have received a copy of the GNU General Public License 1.18 +# along with this program; if not, write to the Free Software 1.19 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 1.20 +# MA 02110-1301, USA. 1.21 +# 1.22 +# 20011 - Eric Joseph-Alexandre <erjo@slitaz.org> 1.23 + 1.24 + 1.25 +CONFIG_DIR=/var/lib/slitaz-vz 1.26 + 1.27 +# Get real network device name from stored config if exist. 1.28 +if [ -f $CONFIG_DIR/network/interfaces ]; then 1.29 + BRIDGE=$(grep ^BRIDGE $CONFIG_DIR/network/interfaces | sed 's/.*"\(.*\)"/\1/') 1.30 + IFACE=$(grep ^INTERFACE $CONFIG_DIR/network/interfaces | sed 's/.*"\(.*\)"/\1/') 1.31 +else 1.32 + BRIDGE=br0 1.33 + IFACE=$(grep ^INTERFACE /etc/network.conf | sed 's/.*"\(.*\)"/\1/') 1.34 + 1.35 + # Store interface infos for the next boot in hd mode 1.36 + mkdir -p $CONFIG_DIR/network 1.37 + echo "BRIDGE=\"$BRIDGE\"" > $CONFIG_DIR/network/interfaces 1.38 + echo "INTERFACE=\"$IFACE\"" >> $CONFIG_DIR/network/interfaces 1.39 +fi 1.40 + 1.41 +# Set Brigde configuration 1.42 +if [ -x /usr/sbin/brctl ]; then 1.43 + if (/usr/sbin/brctl addbr $BRIDGE); then 1.44 + /sbin/ifconfig $IFACE down 1.45 + /sbin/ifconfig $IFACE 0 1.46 + /usr/sbin/brctl addif $BRIDGE $IFACE 1.47 + 1.48 + # Update INTERFACE in /etc/network.conf 1.49 + grep ^INTERFACE /etc/network.conf | grep -q $BRIDGE \ 1.50 + || sed -i "s/^INTERFACE=\"\(.*\)\"/INTERFACE=\"$BRIDGE\"/" /etc/network.conf 1.51 + else 1.52 + echo "Unable to set netwok bridge" 1.53 + fi 1.54 +else 1.55 + echo "Can't find brctl. Make sure you have installed brctl-utils" 1.56 +fi