From: Felix Abecassis Date: Tue, 21 Nov 2017 21:49:36 +0000 (-0800) Subject: lxc-oci: import the environment variables X-Git-Tag: lxc-3.0.0.beta1~176^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=996202e74ad7e421d7e16b9fb7ba2083c139a69b;p=thirdparty%2Flxc.git lxc-oci: import the environment variables Signed-off-by: Felix Abecassis --- diff --git a/templates/lxc-oci.in b/templates/lxc-oci.in index 13decc740..c06c62a67 100755 --- a/templates/lxc-oci.in +++ b/templates/lxc-oci.in @@ -105,6 +105,21 @@ getep() { return } +# get environment from oci image. +getenv() { + if [ "$#" -eq 0 ]; then + return + fi + + configpath="$1" + + cat "${configpath}" > /tmp/config + env=`cat "${configpath}" | jq -c '.config.Env[]'` + + echo "${env}" + return +} + usage() { cat <> "${LXC_CONF_FILE}" echo "lxc.mount.auto = proc:mixed sys:mixed cgroup:mixed" >> "${LXC_CONF_FILE}" +environment=$(getenv ${OCI_CONF_FILE}) +while read -r line; do + echo "lxc.environment = ${line}" >> "${LXC_CONF_FILE}" +done <<< "${environment}" + echo "lxc.uts.name = ${LXC_NAME}" >> "${LXC_CONF_FILE}" # set the hostname cat < ${LXC_ROOTFS}/etc/hostname