diff --git a/lxc-build b/lxc-build index b8a100f..d8cf821 100755 --- a/lxc-build +++ b/lxc-build @@ -30,6 +30,9 @@ lxc.init.cmd = {cmd} lxc.init.uid = {uid} lxc.init.gid = {gid} +# Environment +{env} + # Halt lxc.signal.halt = SIGTERM @@ -48,6 +51,7 @@ class LXCImage: self.name = None self.layers = [] self.mounts = [] + self.env = [] self.uid = 0 self.gid = 0 self.cmd = '/bin/true' @@ -85,6 +89,9 @@ class LXCImage: elif line.startswith('MOUNT'): srcdst = line.split() self.add_mount(srcdst[1], srcdst[2]) + elif line.startswith('ENV'): + env = line.split() + self.add_env(env[1], env[2]) elif line.startswith('USER'): uidgid = line.split() self.set_user(uidgid[1], uidgid[2]) @@ -100,8 +107,9 @@ class LXCImage: # Multiple lower overlayfs layers are ordered from right to left (lower2:lower1:rootfs:upper) rootfs_path = 'overlay:{}:{}'.format(':'.join(self.layers[:-1][::-1]), self.layers[-1]) mount_entries = '\n'.join(['lxc.mount.entry = {} none bind 0 0'.format(m) for m in self.mounts]) + env_entries = '\n'.join(['lxc.environment = {}'.format(e) for e in self.env]) with open(os.path.join(LXC_ROOT, self.name, 'config'), 'w') as fd: - fd.write(CONFIG_TEMPLATE.format(name=self.name, rootfs=rootfs_path, mounts=mount_entries, uid=self.uid, gid=self.gid, cmd=self.cmd)) + fd.write(CONFIG_TEMPLATE.format(name=self.name, rootfs=rootfs_path, mounts=mount_entries, env=env_entries, uid=self.uid, gid=self.gid, cmd=self.cmd)) def run_script(self, script): sh = os.path.join(self.layers[-1], 'run.sh') @@ -130,6 +138,10 @@ class LXCImage: self.mounts.append('{} {}'.format(src, dst)) self.rebuild_config() + def add_env(self, key, value): + self.env.append('{}={}'.format(key, value)) + self.rebuild_config() + def set_user(self, uid, gid): self.uid = uid self.gid = gid diff --git a/solr/lxcfile b/solr/lxcfile index dd9e32b..44a6d5b 100644 --- a/solr/lxcfile +++ b/solr/lxcfile @@ -15,13 +15,11 @@ SCRIPT # Create OS user addgroup -S -g 8983 solr adduser -S -u 8983 -h /var/lib/solr -s /bin/false -g solr -G solr solr - chown -R solr:solr /opt/solr/ - - # Copy basic configuration file to data location - cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml + chown -R solr:solr /opt/solr RUN MOUNT /srv/solr/data var/lib/solr USER 8983 8983 +ENV HOME /var/lib/solr CMD /opt/solr/bin/solr start -f