summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatharina Drexel <katharina.drexel@bfh.ch>2020-10-08 15:12:27 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2020-10-30 04:04:17 +0000
commit795f0c9d4e0bd3f70730ad80a1c7fca94184c996 (patch)
tree47e29fc239c6b38b7a289b922ce72e6bb7b20923
parentAdding overlay options to debconf script. (diff)
downloadcompute-tools-795f0c9d4e0bd3f70730ad80a1c7fca94184c996.tar.xz
compute-tools-795f0c9d4e0bd3f70730ad80a1c7fca94184c996.zip
Adding awk optimizations in configuration file handling.
Signed-off-by: Katharina Drexel <katharina.drexel@bfh.ch>
-rwxr-xr-xlib/container/console2
-rwxr-xr-xlib/container/enter2
-rwxr-xr-xlib/container/limit2
-rwxr-xr-xlib/container/list6
-rwxr-xr-xlib/container/move6
-rwxr-xr-xlib/container/remove6
-rwxr-xr-xlib/container/start44
-rwxr-xr-xlib/container/stop10
8 files changed, 39 insertions, 39 deletions
diff --git a/lib/container/console b/lib/container/console
index 0628a9d..2a41bf5 100755
--- a/lib/container/console
+++ b/lib/container/console
@@ -81,7 +81,7 @@ then
exit 1
fi
-STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
diff --git a/lib/container/enter b/lib/container/enter
index 4c7f890..144a06a 100755
--- a/lib/container/enter
+++ b/lib/container/enter
@@ -81,7 +81,7 @@ then
exit 1
fi
-STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
diff --git a/lib/container/limit b/lib/container/limit
index 42f36a2..233459a 100755
--- a/lib/container/limit
+++ b/lib/container/limit
@@ -121,7 +121,7 @@ then
exit 1
fi
-STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
diff --git a/lib/container/list b/lib/container/list
index 24457de..cf7b148 100755
--- a/lib/container/list
+++ b/lib/container/list
@@ -328,11 +328,11 @@ fi
for CONTAINER in ${CONTAINERS}
do
- STATE="$(machinectl show ${CONTAINER} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+ STATE="$(machinectl show ${CONTAINER} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
if [ -e "${CONFIG}/${CONTAINER}.conf" ]
then
- CONTAINER_SERVER="$(awk -F= '/^cnt.container-server=/ { print $2 }' ${CONFIG}/${CONTAINER}.conf)"
+ CONTAINER_SERVER="$(awk -Fcnt.container-server= '/^cnt.container-server=/ { print $2 }' ${CONFIG}/${CONTAINER}.conf)"
CONTAINER_SERVER="${CONTAINER_SERVER:-false}"
case "${CONTAINER_SERVER}" in
@@ -367,7 +367,7 @@ do
if ls "${MACHINES}/${CONTAINER}/etc/systemd/network"/*.network > /dev/null 2>&1
then
- ADDRESS="$(awk -F= '/^Address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/systemd/network/*.network | head -n1)"
+ ADDRESS="$(awk -FAddress= '/^Address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/systemd/network/*.network | head -n1)"
elif [ -e "${MACHINES}/${CONTAINER}/etc/network/interfaces" ]
then
ADDRESS="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces | head -n1)"
diff --git a/lib/container/move b/lib/container/move
index a31749e..f87e5a8 100755
--- a/lib/container/move
+++ b/lib/container/move
@@ -98,7 +98,7 @@ then
exit 1
fi
-STATE="$(machinectl show ${OLD} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${OLD} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
@@ -145,7 +145,7 @@ mv "${CONFIG}/${OLD}.conf" "${CONFIG}/${NEW}.conf"
mv "${MACHINES}/${OLD}" "${MACHINES}/${NEW}"
# rw bind mounts
-BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NEW}.conf)"
+BIND="$(awk -Fbind= '/^bind=/ { print $2 }' ${CONFIG}/${NEW}.conf)"
if [ -n "${BIND}" ]
then
@@ -172,7 +172,7 @@ then
fi
# ro bind mounts
-BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NEW}.conf)"
+BIND_RO="$(awk -Fbind-ro= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NEW}.conf)"
if [ -n "${BIND_RO}" ]
then
diff --git a/lib/container/remove b/lib/container/remove
index 208de3d..820e45e 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -145,7 +145,7 @@ then
exit 1
fi
-STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
@@ -207,7 +207,7 @@ done
if [ -e "${CONFIG}/${NAME}.conf" ]
then
# Removing rw bind mounts
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -Fbind= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND}" ]
then
@@ -222,7 +222,7 @@ then
fi
# Removing ro bind mounts
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -Fbind-ro= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND_RO}" ]
then
diff --git a/lib/container/start b/lib/container/start
index f972983..6309fb1 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -135,7 +135,7 @@ fi
case "${START}" in
false)
- STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+ STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${STATE}" in
running)
@@ -152,7 +152,7 @@ then
true)
rm -f "${MACHINES}/.#${NAME}.lck"
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
+ VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
for VETH in ${VETHS}
do
@@ -203,7 +203,7 @@ esac
# config
if [ -e "${CONFIG}/${NAME}.conf" ]
then
- CNT_OVERLAY="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CNT_OVERLAY="$(awk -Fcnt.overlay= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
CNT_OVERLAY_OPTIONS="$(awk -Fcnt.overlay-options= '/^cnt.overlay-options=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${CNT_OVERLAY}" ]
@@ -238,7 +238,7 @@ then
done
fi
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -Fbind= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND}" ]
then
@@ -263,7 +263,7 @@ then
done
fi
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -Fbind-ro= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND_RO}" ]
then
@@ -288,7 +288,7 @@ then
done
fi
- BOOT="$(awk -F= '/^boot=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
+ BOOT="$(awk -Fboot= '/^boot=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
case "${BOOT}" in
yes)
@@ -300,7 +300,7 @@ then
;;
esac
- CAPABILITY="$(awk -F= '/^capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CAPABILITY="$(awk -Fcapability= '/^capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
case "${CAPABILITY}" in
"")
@@ -312,10 +312,10 @@ then
;;
esac
- DIRECTORY="$(awk -F= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo ${MACHINES}/${NAMES})"
+ DIRECTORY="$(awk -Fdirectory= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo ${MACHINES}/${NAMES})"
DIRECTORY="--directory ${DIRECTORY}"
- DROP_CAPABILITY="$(awk -F= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ DROP_CAPABILITY="$(awk -Fdrop-capability= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
case "${DROP_CAPABILITY}" in
"")
@@ -327,7 +327,7 @@ then
;;
esac
- LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
+ LINK_JOURNAL="$(awk -Flink-journal= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
case "${LINK_JOURNAL}" in
yes)
@@ -343,7 +343,7 @@ then
NETWORK_VETH_EXTRA=""
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
case "${VETHS}" in
"")
@@ -363,7 +363,7 @@ then
;;
esac
- NETWORK_BRIDGES="$(awk -F= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ NETWORK_BRIDGES="$(awk -Fcnt.network-bridge= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
case "${NETWORK_BRIDGES}" in
"")
@@ -399,7 +399,7 @@ EOF
;;
esac
- PRIVATE_USERS="$(awk -F= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
+ PRIVATE_USERS="$(awk -Fprivate-users= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
case "${PRIVATE_USERS}" in
yes)
@@ -411,7 +411,7 @@ EOF
;;
esac
- REGISTER="$(awk -F= '/^register=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
+ REGISTER="$(awk -Fregister= '/^register=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo yes)"
case "${REGISTER}" in
yes)
@@ -423,7 +423,7 @@ EOF
;;
esac
- BLOCK_IO_DEVICE_WEIGHT="$(awk -F= '/^BlockIODeviceWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_DEVICE_WEIGHT="$(awk -FBlockIODeviceWeight= '/^BlockIODeviceWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BLOCK_IO_DEVICE_WEIGHT}" ]
then
@@ -431,7 +431,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_READ_BANDWIDTH="$(awk -F= '/^BlockIOReadBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_READ_BANDWIDTH="$(awk -FBlockIOReadBandwidth= '/^BlockIOReadBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BLOCK_IO_READ_BANDWIDTH}" ]
then
@@ -439,7 +439,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_WEIGHT="$(awk -F= '/^BlockIOWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_WEIGHT="$(awk -FBlockIOWeight= '/^BlockIOWeight=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BLOCK_IO_WEIGHT}" ]
then
@@ -447,7 +447,7 @@ EOF
SET_PROPERTY="true"
fi
- BLOCK_IO_WRITE_BANDWIDTH="$(awk -F= '/^BlockIOWriteBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BLOCK_IO_WRITE_BANDWIDTH="$(awk -FBlockIOWriteBandwidth=/= '/^BlockIOWriteBandwidth=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BLOCK_IO_WRITE_BANDWIDTH}" ]
then
@@ -455,7 +455,7 @@ EOF
SET_PROPERTY="true"
fi
- CPU_QUOTA="$(awk -F= '/^CPUQuota=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CPU_QUOTA="$(awk -FCPUQuota= '/^CPUQuota=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${CPU_QUOTA}" ]
then
@@ -463,7 +463,7 @@ EOF
SET_PROPERTY="true"
fi
- CPU_SHARES="$(awk -F= '/^CPUShares=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ CPU_SHARES="$(awk -FCPUShares= '/^CPUShares=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${CPU_SHARES}" ]
then
@@ -471,7 +471,7 @@ EOF
SET_PROPERTY="true"
fi
- MEMORY_LIMIT="$(awk -F= '/^MemoryLimit=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ MEMORY_LIMIT="$(awk -FMemoryLimit= '/^MemoryLimit=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${MEMORY_LIMIT}" ]
then
@@ -479,7 +479,7 @@ EOF
SET_PROPERTY="true"
fi
- TASKS_MAX="$(awk -F= '/^TasksMax=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ TASKS_MAX="$(awk -FTasksMax= '/^TasksMax=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${TASKS_MAX}" ]
then
diff --git a/lib/container/stop b/lib/container/stop
index a6bb761..5590747 100755
--- a/lib/container/stop
+++ b/lib/container/stop
@@ -150,7 +150,7 @@ do
fi
done
-STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')"
+STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
case "${CLEAN}" in
true)
@@ -175,7 +175,7 @@ case "${CLEAN}" in
fi
# Removing rw bind mounts
- BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND="$(awk -Fbind= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND}" ]
then
@@ -190,7 +190,7 @@ case "${CLEAN}" in
fi
# Removing ro bind mounts
- BIND_RO="$(awk -F= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ BIND_RO="$(awk -Fbind-ro= '/^bind-ro=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND_RO}" ]
then
@@ -205,7 +205,7 @@ case "${CLEAN}" in
fi
# Removing network configuration
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
case "${VETHS}" in
"")
@@ -257,7 +257,7 @@ machinectl ${MODE} ${NAME}
case "${FORCE}" in
true)
- VETHS="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
+ VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
for VETH in ${VETHS}
do