From: Stéphane Graber Date: Wed, 23 Oct 2013 23:59:22 +0000 (-0400) Subject: lxc-debian: Add hwaddr handling logic X-Git-Tag: lxc-1.0.0.alpha3~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aea1cd3cb730117967c9671aa50f68d2b241c39e;p=thirdparty%2Flxc.git lxc-debian: Add hwaddr handling logic Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- 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