From b71a3b319fa347157973e45e4e08f407e2cb5d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sp=C3=B6hel?= Date: Sun, 9 Jul 2017 15:52:29 +0200 Subject: Making container-tools use nspawn files. --- lib/container/start | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'lib/container/start') diff --git a/lib/container/start b/lib/container/start index 99639f6..b19b482 100755 --- a/lib/container/start +++ b/lib/container/start @@ -20,7 +20,7 @@ set -e COMMAND="$(basename ${0})" -CONFIG="/etc/container-tools/config" +CONFIG="/etc/systemd/nspawn" HOOKS="/etc/container-tools/hooks" MACHINES="/var/lib/machines" @@ -173,9 +173,9 @@ case "${START}" in esac # config -if [ -e "${CONFIG}/${NAME}.conf" ] +if [ -e "${CONFIG}/${NAME}.nspawn" ] then - CNT_OVERLAY="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + CNT_OVERLAY="$(crudini --get ${CONFIG}/${NAME}.nspawn Files Overlay)" if [ -n "${CNT_OVERLAY}" ] then @@ -200,7 +200,7 @@ then done fi - BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BIND="$(crudini --get ${CONFIG}/${NAME}.nspawn Files Bind)" if [ -n "${BIND}" ] then @@ -221,7 +221,7 @@ then done fi - BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BIND_RO="$(crudini --get ${CONFIG}/${NAME}.nspawn Files BindReadOnly)" if [ -n "${BIND_RO}" ] then @@ -242,7 +242,7 @@ then done fi - BOOT="$(awk -F= '/^boot=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)" + BOOT="$(crudini --get ${CONFIG}/${NAME}.nspawn Exec Boot)" case "${BOOT}" in yes) @@ -254,7 +254,7 @@ then ;; esac - CAPABILITY="$(awk -F= '/^capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + CAPABILITY="$(crudini --get ${CONFIG}/${NAME}.nspawn Exec Capability)" case "${CAPABILITY}" in "") @@ -266,10 +266,10 @@ then ;; esac - DIRECTORY="$(awk -F= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo ${MACHINES}/${NAMES})" + DIRECTORY="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsStart directory)" DIRECTORY="--directory ${DIRECTORY}" - DROP_CAPABILITY="$(awk -F= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + DROP_CAPABILITY="$(crudini --get ${CONFIG}/${NAME}.nspawn Exec DropCapability)" case "${DROP_CAPABILITY}" in "") @@ -281,7 +281,7 @@ then ;; esac - LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)" + LINK_JOURNAL="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsStart link-journal)" case "${LINK_JOURNAL}" in yes) @@ -295,7 +295,7 @@ then MACHINE="--machine=${NAME}" - NETWORK_VETH_EXTRA_CONF="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + NETWORK_VETH_EXTRA_CONF="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsStart network-veth-extra)" NETWORK_VETH_EXTRA="" case "${NETWORK_VETH_EXTRA_CONF}" in @@ -324,7 +324,7 @@ EOF ;; esac - NETWORK_BRIDGES="$(awk -F= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + NETWORK_BRIDGES="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsStart cnt.network-bridge)" case "${NETWORK_BRIDGES}" in "") @@ -360,7 +360,7 @@ EOF ;; esac - PRIVATE_USERS="$(awk -F= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)" + PRIVATE_USERS="$(crudini --get ${CONFIG}/${NAME}.nspawn Exec PrivateUsers)" case "${PRIVATE_USERS}" in yes) @@ -372,7 +372,7 @@ EOF ;; esac - REGISTER="$(awk -F= '/^register=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)" + REGISTER="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsStart register)" case "${REGISTER}" in yes) @@ -384,15 +384,15 @@ EOF ;; esac - BLOCK_IO_DEVICE_WEIGHT="$(awk -F= '/^BlockIODeviceWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BLOCK_IO_DEVICE_WEIGHT="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit BlockIODeviceWeight)" if [ -n "${BLOCK_IO_DEVICE_WEIGHT}" ] then - BLOCK_IO_DEVICE_WEIGHT="BlockIODeviceWeight=${BLOCK_IO_DEVICE_WEIGHT}" + BLOCK_IO_DEVICE_WEIGHT="BlockIODeviceWeight=${BLOCK_IO_DEVICE_WEIGHT}"BlockIODeviceWeight SET_PROPERTY="true" fi - BLOCK_IO_READ_BANDWITH="$(awk -F= '/^BlockIOReadBandwith=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BLOCK_IO_READ_BANDWITH="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit BlockIOReadBandwith)" if [ -n "${BLOCK_IO_READ_BANDWITH}" ] then @@ -400,7 +400,7 @@ EOF SET_PROPERTY="true" fi - BLOCK_IO_WEIGHT="$(awk -F= '/^BlockIOWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BLOCK_IO_WEIGHT="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit BlockIOWeight)" if [ -n "${BLOCK_IO_WEIGHT}" ] then @@ -408,7 +408,7 @@ EOF SET_PROPERTY="true" fi - BLOCK_IO_WRITE_BANDWITH="$(awk -F= '/^BlockIOWriteBandwith=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + BLOCK_IO_WRITE_BANDWITH="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit BlockIOWriteBandwith)" if [ -n "${BLOCK_IO_WRITE_BANDWITH}" ] then @@ -416,7 +416,7 @@ EOF SET_PROPERTY="true" fi - CPU_QUOTA="$(awk -F= '/^CPUQuota=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + CPU_QUOTA="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit CPUQuota)" if [ -n "${CPU_QUOTA}" ] then @@ -424,7 +424,7 @@ EOF SET_PROPERTY="true" fi - CPU_SHARES="$(awk -F= '/^CPUShares=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + CPU_SHARES="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit CPUShares)" if [ -n "${CPU_SHARES}" ] then @@ -432,7 +432,7 @@ EOF SET_PROPERTY="true" fi - MEMORY_LIMIT="$(awk -F= '/^MemoryLimit=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + MEMORY_LIMIT="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit MemoryLimit)" if [ -n "${MEMORY_LIMIT}" ] then @@ -440,7 +440,7 @@ EOF SET_PROPERTY="true" fi - TASKS_MAX="$(awk -F= '/^TasksMax=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + TASKS_MAX="$(crudini --get ${CONFIG}/${NAME}.nspawn ContainerToolsLimit TasksMax)" if [ -n "${TASKS_MAX}" ] then -- cgit v1.2.3