From b8ebaa9c78a78e3e3c4043a20d3c84cac9ca7fd1 Mon Sep 17 00:00:00 2001 From: Vicente Olivert Riera Date: Fri, 23 Jan 2015 16:03:13 +0000 Subject: [PATCH] Gentoo template - Add a hwaddr if there is only one veth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reuse the code from the Debian template to associate a hwaddr if there is only one veth interface in the container's config file. Signed-off-by: Vicente Olivert Riera Acked-by: Stéphane Graber --- templates/lxc-gentoo.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/lxc-gentoo.in b/templates/lxc-gentoo.in index d0df8999f..92edcd4c4 100644 --- a/templates/lxc-gentoo.in +++ b/templates/lxc-gentoo.in @@ -681,6 +681,13 @@ container_conf() #at this point if there conf_file="${path}/config" + # if there is exactly one veth network entry, make sure it has an + # associated hwaddr. + nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' ${conf_file} | wc -l` + if [ $nics -eq 1 ]; then + grep -q "^lxc.network.hwaddr" ${conf_file} || 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/.$//')" ${conf_file} + fi + if grep -q "^lxc.rootfs" "${conf_file}" ; then #lxc-create already provided one conf_rootfs_line=""