[omd-commits] OMD Git: omd: omd: added apache start/stop post hooks

git version control git at mathias-kettner.de
Mon May 21 12:20:27 CEST 2012


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

Author:   Sven Nierlein <sven at nierlein.de>
Date:     Mon May 21 11:24:54 2012 +0200
Commiter: Sven Nierlein <sven at nierlein.de>
Date:     Mon May 21 12:19:20 2012 +0200

omd: added apache start/stop post hooks

---

 packages/apache-omd/skel/etc/init.d/apache         |    4 ++++
 packages/omd/skel/.profile                         |    2 +-
 packages/omd/skel/etc/init-hooks.d/README          |   19 ++++++++++++++-----
 packages/thruk/skel.permissions                    |    1 +
 .../skel/etc/init-hooks.d/apache-start-post.sample |    9 +++++++++
 5 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/packages/apache-omd/skel/etc/init.d/apache b/packages/apache-omd/skel/etc/init.d/apache
index 70fb4a9..e98d6f7 100644
--- a/packages/apache-omd/skel/etc/init.d/apache
+++ b/packages/apache-omd/skel/etc/init.d/apache
@@ -119,9 +119,11 @@ case $1 in
   start)
     echo -n "Starting dedicated Apache for site ###SITE###..."
     if apache_wait_start; then
+      __init_hook $0 $1 post 0
       echo 'OK'
       exit 0
     else
+      __init_hook $0 $1 post 1
       echo 'ERROR'
       exit 1
     fi
@@ -129,9 +131,11 @@ case $1 in
   stop)
     echo -n "Stopping dedicated Apache for site ###SITE###..."
     if apache_wait_stop; then
+      __init_hook $0 $1 post 0
       echo 'OK'
       exit 0
     else
+      __init_hook $0 $1 post 1
       echo 'ERROR'
       exit 1
     fi
diff --git a/packages/omd/skel/.profile b/packages/omd/skel/.profile
index 77dfb5c..49735c6 100644
--- a/packages/omd/skel/.profile
+++ b/packages/omd/skel/.profile
@@ -32,5 +32,5 @@ __init_hook() {
   # 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
+  test -x $hook && $hook ${1##*/} $2 $3 $4
 }
diff --git a/packages/omd/skel/etc/init-hooks.d/README b/packages/omd/skel/etc/init-hooks.d/README
index 89fa3d1..37acae6 100644
--- a/packages/omd/skel/etc/init-hooks.d/README
+++ b/packages/omd/skel/etc/init-hooks.d/README
@@ -1,21 +1,30 @@
 In this directory you can put your own custom scripts which extend the startstop-scripts in etc/init.d
 
-The init-hook-scripts are executed by the init-scripts before or after a certain operation. This is defined by following a naming scheme. 
+The init-hook-scripts are executed by the init-scripts before or after a certain operation. This is defined by following a naming scheme.
 
 <name of the init-script>-<name of the operation>-<pre or post>
 
+Post scripts will be run with the exit code of the actual script as
+parameter.
+
 Example:
 nagios-reload-pre will be executed when you run "etc/init.d/nagios reload" or "omd reload nagios" just before the actual reload.
 
 
 Real-live use case:
-Imagine your etc/nagios/conf.d/myconfig is the clone of a git repository. Whenever you reload Nagios, the init-hook-script will do a 
-cd etc/nagios/conf.d/myconfig
-git pull
-and update the config files from the central repository. Then the actual reload follows.
+ - Imagine your etc/nagios/conf.d/myconfig is the clone of a git repository. Whenever you reload Nagios, the init-hook-script will do a
+   cd etc/nagios/conf.d/myconfig
+   git pull
+   and update the config files from the central repository. Then the actual reload follows.
+
+ - Apache stops all fcgi servers on stop ( and therefor on logfile
+   rotation ). There is a sample script which start Thruks fcgi daemon
+   after the apache reload.
 
 Currently only the following scripts can be used, all others are ignored:
 nagios-*-pre
 shinken-*-pre
 icinga-*-pre
 apache-*-pre
+apache-start-post
+apache-stop-post
diff --git a/packages/thruk/skel.permissions b/packages/thruk/skel.permissions
index 8c36d82..38ddf39 100644
--- a/packages/thruk/skel.permissions
+++ b/packages/thruk/skel.permissions
@@ -2,3 +2,4 @@ var/log/thruk.log 0664
 etc/thruk/fcgid_env.sh 0755
 tmp/thruk 0775
 var/thruk 0775
+etc/init-hooks.d/apache-start-pre.sample 0775
diff --git a/packages/thruk/skel/etc/init-hooks.d/apache-start-post.sample b/packages/thruk/skel/etc/init-hooks.d/apache-start-post.sample
new file mode 100644
index 0000000..bc47bf6
--- /dev/null
+++ b/packages/thruk/skel/etc/init-hooks.d/apache-start-post.sample
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# arguments are:
+# <initscriptname> <start|stop> <pre|post> <init script exitcode>
+
+# check return code of apache start
+if [ $4 = 0 ]; then
+  ./etc/init.d/thruk start
+fi



More information about the omd-commits mailing list