summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-10-06 15:05:42 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2018-05-27 05:59:31 +0000
commit1e03e6dc46624f658239c3179875bd28b67fa91a (patch)
tree38731aa38565f40cb5419ea8e17af1af84f1f186 /lib
parentReleasing version 20180503. (diff)
downloadcompute-tools-1e03e6dc46624f658239c3179875bd28b67fa91a.tar.xz
compute-tools-1e03e6dc46624f658239c3179875bd28b67fa91a.zip
Switching to systemd-nspawn configuration files from /etc/container-tools/config.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/container/auto6
-rwxr-xr-xlib/container/create8
-rwxr-xr-xlib/container/list6
-rwxr-xr-xlib/container/move10
-rwxr-xr-xlib/container/remove12
-rwxr-xr-xlib/container/start44
-rwxr-xr-xlib/container/status2
-rwxr-xr-xlib/container/stop10
8 files changed, 49 insertions, 49 deletions
diff --git a/lib/container/auto b/lib/container/auto
index 8477915..85f97a8 100755
--- a/lib/container/auto
+++ b/lib/container/auto
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
Parameters ()
@@ -104,7 +104,7 @@ case "${FORCE}" in
;;
esac
-for FILE in "${CONFIG}"/*.conf
+for FILE in "${CONFIG}"/*.nspawn
do
if grep -Eqs "^ *cnt.auto=force-true" "${FILE}"
then
@@ -113,7 +113,7 @@ do
if grep -Eqs "^ *cnt.auto=(force-true|true)" "${FILE}" && grep -Eqs "^ *cnt.container-server=${HOST}" "${FILE}"
then
- CONTAINER="$(basename ${FILE} .conf)"
+ CONTAINER="$(basename ${FILE} .nspawn)"
cnt ${ACTION} -n ${CONTAINER} ${OPTIONS} || true
fi
diff --git a/lib/container/create b/lib/container/create
index 2ffcfda..767a8c6 100755
--- a/lib/container/create
+++ b/lib/container/create
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
SCRIPTS="/usr/share/container-tools/scripts"
@@ -121,9 +121,9 @@ then
Usage
fi
-if [ -e "${CONFIG}/${NAME}.conf" ]
+if [ -e "${CONFIG}/${NAME}.nspawn" ]
then
- echo "'${NAME}': container already exists or ${CONFIG}/${NAME}.conf has not been removed" >&2
+ echo "'${NAME}': container already exists or ${CONFIG}/${NAME}.nspawn has not been removed" >&2
exit 1
fi
@@ -244,7 +244,7 @@ sed -e "s|@CNT_AUTO@|${CNT_AUTO}|g" \
-e "s|@NETWORK_VETH_EXTRA@|${NETWORK_VETH_EXTRA}|g" \
-e "s|@PRIVATE_USERS@|no|g" \
-e "s|@REGISTER@|yes|g" \
-/usr/share/container-tools/config/container.conf.in > "${CONFIG}/${NAME}.conf"
+/usr/share/container-tools/config/container.nspawn.in > "${CONFIG}/${NAME}.nspawn"
# Run
"${SCRIPTS}/${SCRIPT}" $(echo "${@}" | sed -e 's| -- | |')
diff --git a/lib/container/list b/lib/container/list
index 6fa9eed..6d1efda 100755
--- a/lib/container/list
+++ b/lib/container/list
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
@@ -329,9 +329,9 @@ for CONTAINER in ${CONTAINERS}
do
STATE="$(machinectl show ${CONTAINER} 2>&1 | awk -F= '/^State=/ { print $2 }')"
- if [ -e "${CONFIG}/${CONTAINER}.conf" ]
+ if [ -e "${CONFIG}/${CONTAINER}.nspawn" ]
then
- CONTAINER_SERVER="$(awk -F= '/^cnt.container-server=/ { print $2 }' ${CONFIG}/${CONTAINER}.conf)"
+ CONTAINER_SERVER="$(awk -F= '/^cnt.container-server=/ { print $2 }' ${CONFIG}/${CONTAINER}.nspawn)"
CONTAINER_SERVER="${CONTAINER_SERVER:-false}"
case "${CONTAINER_SERVER}" in
diff --git a/lib/container/move b/lib/container/move
index e533b0e..d9f60e1 100755
--- a/lib/container/move
+++ b/lib/container/move
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
@@ -140,11 +140,11 @@ do
done
# Run
-mv "${CONFIG}/${OLD}.conf" "${CONFIG}/${NEW}.conf"
+mv "${CONFIG}/${OLD}.nspawn" "${CONFIG}/${NEW}.nspawn"
mv "${MACHINES}/${OLD}" "${MACHINES}/${NEW}"
# rw bind mounts
-BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND}" ]
then
@@ -171,7 +171,7 @@ then
fi
# ro bind mounts
-BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND_RO}" ]
then
@@ -198,7 +198,7 @@ then
fi
# config
-sed -i -e "s|${OLD}|${NEW}|g" "${CONFIG}/${NEW}.conf"
+sed -i -e "s|${OLD}|${NEW}|g" "${CONFIG}/${NEW}.nspawn"
# Post hooks
for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}"
diff --git a/lib/container/remove b/lib/container/remove
index e8dd653..8ce87bb 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
@@ -111,7 +111,7 @@ then
Usage
fi
-if [ ! -e "${MACHINES}/${NAME}" ] && [ ! -e "${CONFIG}/${NAME}.conf" ]
+if [ ! -e "${MACHINES}/${NAME}" ] && [ ! -e "${CONFIG}/${NAME}.nspawn" ]
then
echo "'${NAME}': no such container" >&2
exit 1
@@ -176,10 +176,10 @@ do
done
# data
-if [ -e "${CONFIG}/${NAME}.conf" ]
+if [ -e "${CONFIG}/${NAME}.nspawn" ]
then
# Removing rw bind mounts
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND}" ]
then
@@ -194,7 +194,7 @@ then
fi
# Removing ro bind mounts
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND_RO}" ]
then
@@ -211,7 +211,7 @@ fi
# Run
rm --preserve-root --one-file-system -rf ${RM_OPTIONS} "${MACHINES}/${NAME}"
-rm -f ${RM_OPTIONS} "${CONFIG}/${NAME}.conf"
+rm -f ${RM_OPTIONS} "${CONFIG}/${NAME}.nspawn"
# Post hooks
for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}"
diff --git a/lib/container/start b/lib/container/start
index e4b2ee6..6d43af8 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
@@ -175,9 +175,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="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${CNT_OVERLAY}" ]
then
@@ -202,7 +202,7 @@ then
done
fi
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND}" ]
then
@@ -227,7 +227,7 @@ then
done
fi
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND_RO}" ]
then
@@ -252,7 +252,7 @@ then
done
fi
- BOOT="$(awk -F= '/^boot=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
+ BOOT="$(awk -F= '/^boot=/ { print $2 }' ${CONFIG}/${NAME}.nspawn || echo yes)"
case "${BOOT}" in
yes)
@@ -264,7 +264,7 @@ then
;;
esac
- CAPABILITY="$(awk -F= '/^capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CAPABILITY="$(awk -F= '/^capability=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
case "${CAPABILITY}" in
"")
@@ -276,10 +276,10 @@ then
;;
esac
- DIRECTORY="$(awk -F= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo ${MACHINES}/${NAMES})"
+ DIRECTORY="$(awk -F= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.nspawn || echo ${MACHINES}/${NAMES})"
DIRECTORY="--directory ${DIRECTORY}"
- DROP_CAPABILITY="$(awk -F= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ DROP_CAPABILITY="$(awk -F= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
case "${DROP_CAPABILITY}" in
"")
@@ -291,7 +291,7 @@ then
;;
esac
- LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
+ LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.nspawn || echo no)"
case "${LINK_JOURNAL}" in
yes)
@@ -307,7 +307,7 @@ then
NETWORK_VETH_EXTRA=""
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
case "${VETHS}" in
"")
@@ -327,7 +327,7 @@ then
;;
esac
- NETWORK_BRIDGES="$(awk -F= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ NETWORK_BRIDGES="$(awk -F= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
case "${NETWORK_BRIDGES}" in
"")
@@ -363,7 +363,7 @@ EOF
;;
esac
- PRIVATE_USERS="$(awk -F= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
+ PRIVATE_USERS="$(awk -F= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.nspawn || echo no)"
case "${PRIVATE_USERS}" in
yes)
@@ -375,7 +375,7 @@ EOF
;;
esac
- REGISTER="$(awk -F= '/^register=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
+ REGISTER="$(awk -F= '/^register=/ { print $2 }' ${CONFIG}/${NAME}.nspawn || echo yes)"
case "${REGISTER}" in
yes)
@@ -387,7 +387,7 @@ EOF
;;
esac
- BLOCK_IO_DEVICE_WEIGHT="$(awk -F= '/^BlockIODeviceWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_DEVICE_WEIGHT="$(awk -F= '/^BlockIODeviceWeight=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BLOCK_IO_DEVICE_WEIGHT}" ]
then
@@ -395,7 +395,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_READ_BANDWIDTH="$(awk -F= '/^BlockIOReadBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_READ_BANDWIDTH="$(awk -F= '/^BlockIOReadBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BLOCK_IO_READ_BANDWIDTH}" ]
then
@@ -403,7 +403,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_WEIGHT="$(awk -F= '/^BlockIOWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_WEIGHT="$(awk -F= '/^BlockIOWeight=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BLOCK_IO_WEIGHT}" ]
then
@@ -411,7 +411,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_WRITE_BANDWIDTH="$(awk -F= '/^BlockIOWriteBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_WRITE_BANDWIDTH="$(awk -F= '/^BlockIOWriteBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BLOCK_IO_WRITE_BANDWIDTH}" ]
then
@@ -419,7 +419,7 @@ EOF
SET_PROPERTY="true"
fi
- CPU_QUOTA="$(awk -F= '/^CPUQuota=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CPU_QUOTA="$(awk -F= '/^CPUQuota=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${CPU_QUOTA}" ]
then
@@ -427,7 +427,7 @@ EOF
SET_PROPERTY="true"
fi
- CPU_SHARES="$(awk -F= '/^CPUShares=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CPU_SHARES="$(awk -F= '/^CPUShares=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${CPU_SHARES}" ]
then
@@ -435,7 +435,7 @@ EOF
SET_PROPERTY="true"
fi
- MEMORY_LIMIT="$(awk -F= '/^MemoryLimit=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ MEMORY_LIMIT="$(awk -F= '/^MemoryLimit=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${MEMORY_LIMIT}" ]
then
@@ -443,7 +443,7 @@ EOF
SET_PROPERTY="true"
fi
- TASKS_MAX="$(awk -F= '/^TasksMax=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ TASKS_MAX="$(awk -F= '/^TasksMax=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${TASKS_MAX}" ]
then
diff --git a/lib/container/status b/lib/container/status
index 9c5ab20..32dd928 100755
--- a/lib/container/status
+++ b/lib/container/status
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
diff --git a/lib/container/stop b/lib/container/stop
index 5099005..514e098 100755
--- a/lib/container/stop
+++ b/lib/container/stop
@@ -22,7 +22,7 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
+CONFIG="/etc/systemd/nspawn"
HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
@@ -128,7 +128,7 @@ STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
case "${CLEAN}" in
true)
# Removing overlay mounts
- CNT_OVERLAY="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CNT_OVERLAY="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${CNT_OVERLAY}" ]
then
@@ -148,7 +148,7 @@ case "${CLEAN}" in
fi
# Removing rw bind mounts
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND}" ]
then
@@ -163,7 +163,7 @@ case "${CLEAN}" in
fi
# Removing ro bind mounts
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
if [ -n "${BIND_RO}" ]
then
@@ -178,7 +178,7 @@ case "${CLEAN}" in
fi
# Removing network configuration
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.nspawn)"
case "${VETHS}" in
"")