]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-clone: update any hwaddrs
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 31 Jul 2012 14:01:28 +0000 (16:01 +0200)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Tue, 31 Jul 2012 14:01:28 +0000 (16:01 +0200)
Since we are creating a new container it should not share a macaddr with
the original container.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/934256

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc-clone.in

index 4a9f581bf1ec0100c28caeff6bd9407ee049472e..78058ecb9ae8a978ff41e87386161cbd6c5a6c42 100644 (file)
@@ -259,6 +259,20 @@ if [ -f $rootfs/etc/dhcp/dhclient.conf ]; then
     sed -i "s/send host-name.*$/send host-name \"$hostname\";/" $rootfs/etc/dhcp/dhclient.conf
 fi
 
+c=$lxc_path/$lxc_new/config
+# change hwaddrs
+mv ${c} ${c}.old
+(
+while read line; do
+       if [ "${line:0:18}" = "lxc.network.hwaddr" ]; then
+               echo "lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')"
+       else
+               echo $line
+       fi
+done
+) < ${c}.old > ${c}
+rm -f ${c}.old
+
 # set the hostname
 cat <<EOF > $rootfs/etc/hostname
 $hostname