From 039dc0534e1f66c5fb84ca7dec79d4d313f41df2 Mon Sep 17 00:00:00 2001
From: Axel Hahn <ax2002@gmx.net>
Date: Fri, 7 Oct 2022 00:46:08 +0200
Subject: [PATCH] function to exec all hook scripts of a given hook

---
 jobhelper.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/jobhelper.sh b/jobhelper.sh
index d1efb90..c6c5314 100755
--- a/jobhelper.sh
+++ b/jobhelper.sh
@@ -179,6 +179,26 @@ function _j_getvar(){
 # read local jobdescription and set as variables
 # ------------------------------------------------------------
 
+# ------------------------------------------------------------
+# execute hook skripts in a given directory in alphabetic order
+# param  string  name of hook directory
+# ------------------------------------------------------------
+function _j_runHooks(){
+  local _hookdir=$1
+  echo ">>> HOOKS $_hookdir"
+  for hookscript in $( ls -1a "$_hookdir" | grep -v "^\.*$" | sort )
+  do
+    if [ -x "$hookscript" ]; then
+      echo "start $hookscript ..."
+      $hookscript
+    else
+      echo "SKIP: $hookscript (not executable)"
+    fi
+  done
+
+  echo
+}
+
 # ------------------------------------------------------------
 # parse day of week and day of month and echo 0 or 1
 #
-- 
GitLab