diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-06-05 08:27:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-06-05 08:27:42 +0000 |
commit | df8f3eccb410d23ea46774816ea47370fe7ef406 (patch) | |
tree | 2d4fbcec55e6ab05c42348ea2bbbe80eb7f16414 /libexec/container/auto | |
parent | Adding upstream version 20220604. (diff) | |
download | open-infrastructure-compute-tools-df8f3eccb410d23ea46774816ea47370fe7ef406.tar.xz open-infrastructure-compute-tools-df8f3eccb410d23ea46774816ea47370fe7ef406.zip |
Adding upstream version 20220605.upstream/20220605
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libexec/container/auto')
-rwxr-xr-x | libexec/container/auto | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/libexec/container/auto b/libexec/container/auto index 927eae0..83c5c50 100755 --- a/libexec/container/auto +++ b/libexec/container/auto @@ -111,17 +111,50 @@ esac for FILE in "${CONFIG}"/*.conf do - if grep -Eqs "^ *cnt.auto=force-true" "${FILE}" + if ! grep -Eqs "^ *cnt.container-server=${HOST}" "${FILE}" then - OPTIONS="${OPTIONS} -f" + continue fi - if grep -Eqs "^ *cnt.auto=(force-true|true)" "${FILE}" && grep -Eqs "^ *cnt.container-server=${HOST}" "${FILE}" - then - CONTAINER="$(basename ${FILE} .conf)" - - cnt ${ACTION} -n ${CONTAINER} ${OPTIONS} || true - fi + CONTAINER="$(basename ${FILE} .conf)" + CNT_AUTO="$(grep -Es "^ *cnt.auto=" ${FILE} | awk -F= '{ print $2 }')" + + case "${ACTION}" in + start) + case "${CNT_AUTO}" in + force-true) + OPTIONS="${OPTIONS} -f" + + cnt ${ACTION} -n ${CONTAINER} ${OPTIONS} || true + ;; + + last-on) + if grep -qs start "/var/lib/${SOFTWARE}/state/${CONTAINER}.run" || \ + [ ! -e "/var/lib/${SOFTWARE}/state/${CONTAINER}.run" ] + then + cnt start -n ${CONTAINER} ${OPTIONS} -f || true + fi + ;; + + last-off) + if grep -qs start "/var/lib/${SOFTWARE}/state/${CONTAINER}.run" + then + cnt start -n ${CONTAINER} ${OPTIONS} -f || true + fi + ;; + + true) + cnt ${ACTION} -n ${CONTAINER} ${OPTIONS} || true + ;; + esac + ;; + + stop) + OPTIONS="${OPTIONS} -f --stateless" + + cnt ${ACTION} -n ${CONTAINER} ${OPTIONS} || true + ;; + esac done # Post hooks |