# Template used to create this container: /usr/share/lxc/templates/lxc-eole
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)
%set %%nettype = {'bridge':'veth', 'macvlan':'macvlan'}
%set %%name = %%current_container.name
%set %%base = %%os.path.dirname(%%current_container.path)

# Common configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf

# Enable mounting iso9660 FS in containers
%if %%name == 'ltspserver'
lxc.apparmor.profile = lxc-container-for-eclair
%else
lxc.apparmor.profile = lxc-container-default-with-cdrom
%end if

# Container specific configuration
lxc.uts.name = mail
lxc.arch = amd64
lxc.rootfs.path = %%current_container.path
lxc.mount.fstab = %%base/fstab

# Automatic start at bootup
lxc.start.auto = 1
# lxc.group = ?
# lxc.start.order = ?

# Network configuration
#
%for %%idx, %%interface in %%enumerate(%%current_container.interfaces)
 %if 'ip' not in %%interface or %%interface.ip is None
  %continue
 %end if
# %%interface.name on %%interface.linkto
 %if %%interface.linkto == 'br0'
  %set %%link = 'br0'
 %else
  %set %%link = %%getVar("nom_zone_" + %%interface.linkto)
 %end if
lxc.net.%%{idx}.type = %%nettype[%%interface.method]
lxc.net.%%{idx}.link = %%link
lxc.net.%%{idx}.flags = up
lxc.net.%%{idx}.name = %%interface.name
lxc.net.%%{idx}.mtu = 1500
 %if %%interface.method == 'bridge'
lxc.net.%%{idx}.veth.pair = %%{current_container.name}_%%link.lstrip('br')
 %elif %%interface.method == 'macvlan'
lxc.net.%%{idx}.macvlan.mode = bridge
 %end if
lxc.net.%%{idx}.ipv4.address = %%interface.ip/%%calc_classe(%%interface.mask)
 %if %%interface.name == %%current_container.gateway.interface
lxc.net.%%{idx}.ipv4.gateway = %%current_container.gateway.ip
 %end if
µµµµµµµµµµ Generate MAC address from MD5 of static informations
 %set %%salt = %%current_container.name + %%interface.linkto + %%interface.ip
 %set %%md5 = %%hashlib.md5(%%salt.encode()).hexdigest()
lxc.net.%%{idx}.hwaddr = 00:16:3e:%%md5[0:2]:%%md5[2:4]:%%md5[4:6]
%end for

lxc.hook.autodev = %%base/devices.hook
%if 'disknods' in %%current_container and %%len(%%current_container.disknods) > 0
#
## Extra devices of %%current_container.name
#
 %for %%dev in %%current_container.disknods
# %%dev.name
lxc.cgroup.devices.%%dev.permission = %%dev.type %%dev.major:%%dev.minor %%dev.mode
 %end for
%end if
%for %%dev in %%cdrom_devices
# cdrom %%dev
lxc.cgroup.devices.allow = b %%dev.cdrom_major:%%dev.cdrom_minor rm
%end for
