From e9f52f24c29f798d618c6e8e68ceabbd86bd0c6c Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 5 Dec 2022 01:39:05 +0100 Subject: hooks! --- lib/hooks.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/hooks.sh (limited to 'lib/hooks.sh') diff --git a/lib/hooks.sh b/lib/hooks.sh new file mode 100644 index 0000000..8d5fc1d --- /dev/null +++ b/lib/hooks.sh @@ -0,0 +1,18 @@ +# Functions for hooks + +# 1: Name of hook +call_hook() { + if [ ! -x "hooks/$1.hook" ]; then + debug "$1.hook was not found. Skipping." + return + fi + + debug "Running hook $1" + + hooks/$1.hook 2>&1 | (while read line; do echo [hook: $1] $line; done) + RET=${PIPESTATUS[0]} + + if [ $RET -ne 0 ]; then + warning "Hook $1 exitet with code $RET" + fi +} -- cgit v1.2.3