From aea1cd3cb730117967c9671aa50f68d2b241c39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 23 Oct 2013 19:59:22 -0400 Subject: [PATCH] lxc-debian: Add hwaddr handling logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- templates/lxc-debian.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in index 4dd491026..645fe8d73 100644 --- a/templates/lxc-debian.in +++ b/templates/lxc-debian.in @@ -207,6 +207,13 @@ copy_configuration() hostname=$3 arch=$4 + # if there is exactly one veth network entry, make sure it has an + # associated hwaddr. + nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` + if [ $nics -eq 1 ]; then + grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config + fi + grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config lxc.tty = 4