From: Serge Hallyn Date: Tue, 31 Jul 2012 14:01:28 +0000 (+0200) Subject: lxc-clone: update any hwaddrs X-Git-Tag: lxc-0.8.0~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b605a1d1e2ad65c235a43bf61dbd0bc240809c1;p=thirdparty%2Flxc.git lxc-clone: update any hwaddrs 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 Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in index 4a9f581bf..78058ecb9 100644 --- a/src/lxc/lxc-clone.in +++ b/src/lxc/lxc-clone.in @@ -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 < $rootfs/etc/hostname $hostname