From 2800164883ad19e22a8e8fe35d5f3c46eff9d1d7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 5 Dec 2016 08:48:22 +0100 Subject: Enabling pre and post hooks in container commands. Signed-off-by: Daniel Baumann --- lib/container/stop | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/container/stop') diff --git a/lib/container/stop b/lib/container/stop index 3327025..e91d0c6 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -21,6 +21,7 @@ set -e COMMAND="$(basename ${0})" CONFIG="/etc/container-tools/config" +HOOKS="/etc/container-tools/hooks" MACHINES="/var/lib/machines" CLEAN="false" @@ -90,6 +91,15 @@ then exit 1 fi +# Pre hooks +for FILE in "${HOOKS}/pre-${COMMAND}".* "${HOOKS}/${NAME}.pre-${COMMAND}" +do + if [ -x "${FILE}" ] + then + "${FILE}" + fi +done + STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')" case "${CLEAN}" in @@ -182,3 +192,12 @@ esac # Run machinectl ${MODE} ${NAME} + +# Post hooks +for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}" +do + if [ -x "${FILE}" ] + then + "${FILE}" + fi +done -- cgit v1.2.3