# -*- coding: utf-8 -*- LXC_CONTAINER = '''# Image name lxc.uts.name = {name} # Network lxc.net.0.type = veth lxc.net.0.link = lxcbr0 lxc.net.0.flags = up lxc.net.0.ipv4.address = {ipv4}/16 lxc.net.0.ipv4.gateway = 172.17.0.1 # Volumes lxc.rootfs.path = /var/lib/lxc/{name}/rootfs # Mounts lxc.mount.entry = shm dev/shm tmpfs rw,nodev,noexec,nosuid,relatime,mode=1777,create=dir 0 0 lxc.mount.entry = /etc/hosts etc/hosts none bind,create=file 0 0 lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,create=file 0 0{mounts} # Init lxc.init.uid = {uid} lxc.init.gid = {gid} lxc.init.cwd = {cwd} lxc.init.cmd = {cmd} # Environment lxc.environment = PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin{env} # Halt lxc.signal.halt = {halt} # Log lxc.console.size = 1MB lxc.console.logfile = /var/log/lxc/{name}.log # ID map lxc.idmap = u 0 100000 65536 lxc.idmap = g 0 100000 65536 # Hooks lxc.hook.pre-start = /usr/bin/lxchelper prepare {layers} lxc.hook.post-stop = /usr/bin/lxchelper cleanup # Other lxc.arch = linux64 lxc.include = /usr/share/lxc/config/common.conf lxc.include = /usr/share/lxc/config/userns.conf ''' SERVICE = """#!/sbin/openrc-run description="{container} LXC container" depend() {{ need cgroups {depends} }} start() {{ lxc-start {container} }} {start_post} stop() {{ lxc-stop {container} }} """