[omd-commits] OMD Git: omd: omd: add init-hook call (pre only) to nagios/shinken/icinga/ apache-initscripts

git version control git at mathias-kettner.de
Sun May 20 23:24:55 CEST 2012


Module:   omd
Branch:   master
Commit:   1a819fba43dc6042559d3c9eef60a52b0788e773
URL:      http://omdistro.org/projects/omd/repository/revisions/1a819fba43dc6042559d3c9eef60a52b0788e773

Author:   Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Sat May 19 22:52:02 2012 +0200
Commiter: Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Sun May 20 23:23:56 2012 +0200

omd: add init-hook call (pre only) to nagios/shinken/icinga/apache-initscripts

---

 packages/apache-omd/skel/etc/init.d/apache         |    1 +
 packages/icinga/skel/etc/init.d/icinga             |    1 +
 packages/nagios/skel/etc/init.d/nagios             |    3 ++-
 packages/omd/skel/.profile                         |    9 +++++++++
 packages/omd/skel/etc/init-hooks.d/README          |    1 +
 .../omd/skel/etc/init-hooks.d/sample-start-pre     |    1 +
 packages/shinken/skel/etc/init.d/shinken           |    1 +
 7 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/packages/apache-omd/skel/etc/init.d/apache b/packages/apache-omd/skel/etc/init.d/apache
index 0123049..39159ef 100644
--- a/packages/apache-omd/skel/etc/init.d/apache
+++ b/packages/apache-omd/skel/etc/init.d/apache
@@ -112,6 +112,7 @@ kill_stale_php_cgis()
     done
 }
 
+init-hook $0 $1 pre
 case $1 in 
   start)
     echo -n "Starting dedicated Apache for site ###SITE###..."
diff --git a/packages/icinga/skel/etc/init.d/icinga b/packages/icinga/skel/etc/init.d/icinga
index 1ef75f1..7bf4947 100755
--- a/packages/icinga/skel/etc/init.d/icinga
+++ b/packages/icinga/skel/etc/init.d/icinga
@@ -180,6 +180,7 @@ case "$1" in start|restart|reload|checkconfig)
     fi
 esac
           
+init-hook $0 $1 pre
 case "$1" in
     start)
          echo -n "Starting icinga..."
diff --git a/packages/nagios/skel/etc/init.d/nagios b/packages/nagios/skel/etc/init.d/nagios
index 54de800..5ad795d 100755
--- a/packages/nagios/skel/etc/init.d/nagios
+++ b/packages/nagios/skel/etc/init.d/nagios
@@ -160,7 +160,8 @@ case "$1" in start|restart|reload|checkconfig)
         exit 1
     fi
 esac
-          
+
+init-hook $0 $1 pre
 case "$1" in
     start)
          echo -n "Starting nagios..."
diff --git a/packages/omd/skel/.profile b/packages/omd/skel/.profile
index 74f035d..3a38c41 100644
--- a/packages/omd/skel/.profile
+++ b/packages/omd/skel/.profile
@@ -25,3 +25,12 @@ fi
 if [ "$BASH" -a -s ~/.bashrc -a -z "$BASHRC" ]; then
     . ~/.bashrc
 fi
+
+function init-hook() {
+  # Takes 3 parameters
+  # 1. Name of the init-script (can be the full path name, we will only use the file part)
+  # 2. The command the init-script was called with (start, stop, reload,..)
+  # 3. A fixed string, either "pre" os "post"
+  hook=$(printf "###ROOT###/etc/init-hooks.d/%s-%s-%s" ${1##*/} $2 $3)
+  test -x $hook && $hook ${1##*/} $2 $3
+}
diff --git a/packages/omd/skel/etc/init-hooks.d/README b/packages/omd/skel/etc/init-hooks.d/README
new file mode 100644
index 0000000..c8acb73
--- /dev/null
+++ b/packages/omd/skel/etc/init-hooks.d/README
@@ -0,0 +1 @@
+In this directory you can put blabla
diff --git a/packages/omd/skel/etc/init-hooks.d/sample-start-pre b/packages/omd/skel/etc/init-hooks.d/sample-start-pre
new file mode 100644
index 0000000..6e7f774
--- /dev/null
+++ b/packages/omd/skel/etc/init-hooks.d/sample-start-pre
@@ -0,0 +1 @@
+echo do some stuff at the beginning of the start function
diff --git a/packages/shinken/skel/etc/init.d/shinken b/packages/shinken/skel/etc/init.d/shinken
index d3259b3..9a1e5af 100644
--- a/packages/shinken/skel/etc/init.d/shinken
+++ b/packages/shinken/skel/etc/init.d/shinken
@@ -427,6 +427,7 @@ do_check() {
 #
 # check for our command
 #
+init-hook $0 $1 pre
 case "$CMD" in
   start)
     [ "$VERBOSE" != no ] && echo "Starting $NAME..."



More information about the omd-commits mailing list