1
edit
Changes
A hack that can be used on ancient versions of vzctl.
==== method for vzctl version <= 3.0.22 ====
1. First, edit the CT's configuration to specify what is the host bridge , and to indicate that a custom script should be run when starting up a CT.
#!/bin/bash
EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
</pre>
This may not work for particularily old versions of vzctl, e.g., the version 3.0.11 that ships with Debian Etch. For those versions, you can try a hack: Use the custom script <code>/etc/vz/conf/$VID.mount</code> which is available, even in these old versions. But it gets called too early, before the networking has been set up. But it can start some background process, which waits and occasionally polls until $VZHOSTIF has become available. Here is one way to go about it:
<pre>
#!/bin/bash
CONFIGFILE="/etc/vz/conf/$VEID.conf"
if [ -f "$CONFIGFILE" ]
then
. "$CONFIGFILE"
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`
export VZHOSTIF
export VZHOSTBR
# Fork into the background and try a few times,
# until the host side of the interface appears:
/bin/bash -c 'for i in 5 10 20 40 80 160
do
if ifconfig -a | grep -q "$VZHOSTIF"
then
exec /usr/sbin/vznetaddbr
else
sleep "$i"
fi
done
' &
# In the meantime, let the CT's start process continue,
# or else the interface will never appear:
exit 0
else
$0: Config file "$CONFIGFILE" does not exist.
exit 1
fi
</pre>