From 80d77828d857b1c47bd15688ed0371d90e808068 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 7 May 2013 01:53:52 -0300 Subject: [PATCH] Set debian boxes network hwaddr Required by failback mechanism used to fetch container ip based on dnsmasq leases --- boxes/debian/lxc-template | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index ea46245..2036270 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -152,6 +152,15 @@ copy_configuration() rootfs=$2 name=$3 + # 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 || cat <> $path/config +lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//') +EOF + fi + grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config lxc.tty = 4