Make interface and resolv.conf configurable
This commit is contained in:
parent
79b02c90fe
commit
e2d4a15251
2
APKBUILD
2
APKBUILD
@ -1,7 +1,7 @@
|
||||
# Contributor: Disassembler <disassembler@dasm.cz>
|
||||
# Maintainer: Disassembler <disassembler@dasm.cz>
|
||||
pkgname=spoc
|
||||
pkgver=0.9.2
|
||||
pkgver=0.9.3
|
||||
pkgrel=0
|
||||
pkgdesc="SPOC application, container, and image manager"
|
||||
url="https://spotter.vm/"
|
||||
|
@ -2,6 +2,7 @@
|
||||
data-dir = /var/lib/spoc/
|
||||
log-dir = /var/log/spoc/
|
||||
network-interface = spocbr0
|
||||
resolv-conf = /etc/resolv.conf
|
||||
|
||||
[publish]
|
||||
publish-dir = /srv/build/spoc/
|
||||
|
@ -10,6 +10,7 @@ config = configparser.ConfigParser()
|
||||
config.read(CONFIG_FILE)
|
||||
|
||||
NETWORK_INTERFACE = config.get('general', 'network-interface', fallback='spocbr0')
|
||||
RESOLV_CONF = config.get('general', 'resolv-conf', fallback='/etc/resolv.conf')
|
||||
|
||||
DATA_DIR = config.get('general', 'data-dir', fallback='/var/lib/spoc/')
|
||||
APPS_DIR = os.path.join(DATA_DIR, 'apps/')
|
||||
|
@ -146,7 +146,22 @@ class Container:
|
||||
ip_address, ip_netmask, ip_gateway = net.request_ip(self.name)
|
||||
# Write LXC configuration file
|
||||
with open(self.config_path, 'w') as f:
|
||||
f.write(templates.LXC_CONTAINER_TEMPLATE.format(name=self.name, ip_address=ip_address, ip_netmask=ip_netmask, ip_gateway=ip_gateway, rootfs=self.rootfs_path, hosts=config.HOSTS_FILE, mounts=mounts, env=env, uid=uid, gid=gid, cmd=cmd, cwd=cwd, halt=halt, log=self.log_path))
|
||||
f.write(templates.LXC_CONTAINER_TEMPLATE.format(name=self.name,
|
||||
interface=config.NETWORK_INTERFACE,
|
||||
resolv_conf=config.RESOLV_CONF,
|
||||
ip_address=ip_address,
|
||||
ip_netmask=ip_netmask,
|
||||
ip_gateway=ip_gateway,
|
||||
rootfs=self.rootfs_path,
|
||||
hosts=config.HOSTS_FILE,
|
||||
mounts=mounts,
|
||||
env=env,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
cmd=cmd,
|
||||
cwd=cwd,
|
||||
halt=halt,
|
||||
log=self.log_path))
|
||||
repo_local.register_container(self.name, self.get_definition())
|
||||
|
||||
def destroy(self):
|
||||
|
@ -5,7 +5,7 @@ lxc.uts.name = {name}
|
||||
|
||||
# Network
|
||||
lxc.net.0.type = veth
|
||||
lxc.net.0.link = spocbr0
|
||||
lxc.net.0.link = {interface}
|
||||
lxc.net.0.flags = up
|
||||
lxc.net.0.ipv4.address = {ip_address}/{ip_netmask}
|
||||
lxc.net.0.ipv4.gateway = {ip_gateway}
|
||||
@ -15,7 +15,7 @@ lxc.rootfs.path = {rootfs}
|
||||
|
||||
# Mounts
|
||||
lxc.mount.entry = shm dev/shm tmpfs rw,nodev,noexec,nosuid,relatime,mode=1777,create=dir 0 0
|
||||
lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro,create=file 0 0
|
||||
lxc.mount.entry = {resolv_conf} etc/resolv.conf none bind,ro,create=file 0 0
|
||||
lxc.mount.entry = {hosts} etc/hosts none bind,ro,create=file 0 0
|
||||
{mounts}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user