]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-debian: Add hwaddr handling logic
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 23 Oct 2013 23:59:22 +0000 (19:59 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 24 Oct 2013 00:15:44 +0000 (20:15 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
templates/lxc-debian.in

index 4dd491026b2874448ddf63dc7687c4b2d7200d09..645fe8d73117ac6bfc0184de34011ced32a88161 100644 (file)
@@ -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 <<EOF >> $path/config
 lxc.tty = 4