From 264a8bba257b9e5ed3202c1d76da4d95abb4491a Mon Sep 17 00:00:00 2001 From: xZero707 Date: Tue, 26 Jul 2022 21:33:28 +0200 Subject: [PATCH] Add exit handler --- rootfs/etc/cont-init.d/10-init-wordpress | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rootfs/etc/cont-init.d/10-init-wordpress b/rootfs/etc/cont-init.d/10-init-wordpress index fa9304e..a3c1785 100644 --- a/rootfs/etc/cont-init.d/10-init-wordpress +++ b/rootfs/etc/cont-init.d/10-init-wordpress @@ -2,6 +2,20 @@ # Designed to replace original, overcomplicated entrypoint script from official wordpress docker repository # Why not use already available tools instead?! +# Register exit handler +trap scriptExitHandler EXIT + +function scriptExitHandler() { + LAST_EXIT_CODE=$? + if [ "${LAST_EXIT_CODE}" = "0" ]; then + echp "> Script finished successfully" + exit "${LAST_EXIT_CODE}" + fi + + echo "> Script finished with an error" + exit "${LAST_EXIT_CODE}" +} + # Applies patch for making WordPress updates impossible function disableUpdatesPatch() { DISABLE_WP_UPDATES="${ENFORCE_DISABLE_WP_UPDATES:-true}"