Gentoo template - Add a hwaddr if there is only one veth

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 <Vincent.Riera@imgtec.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Vicente Olivert Riera 2015-01-23 16:03:13 +00:00 committed by Stéphane Graber
parent 1f3fc0d73a
commit b8ebaa9c78

View File

@ -681,6 +681,13 @@ container_conf()
#at this point if there #at this point if there
conf_file="${path}/config" 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 if grep -q "^lxc.rootfs" "${conf_file}" ; then
#lxc-create already provided one #lxc-create already provided one
conf_rootfs_line="" conf_rootfs_line=""