[omd-commits] OMD Git: omd: gearman: nicer error message when user deletes gearmans etc

git version control git at mathias-kettner.de
Sat Jun 25 16:59:03 CEST 2011


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

Author:   Sven Nierlein <sven at nierlein.de>
Date:     Thu Jun 23 11:06:37 2011 +0200
Commiter: Sven Nierlein <sven at nierlein.de>
Date:     Sat Jun 25 16:57:04 2011 +0200

gearman: nicer error message when user deletes gearmans etc

Signed-off-by: Sven Nierlein <sven at nierlein.de>

---

 packages/gearmand/GEARMAND_PORT.hook     |    1 +
 packages/mod-gearman/GEARMAN_WORKER.hook |    1 +
 packages/mod-gearman/MOD_GEARMAN.hook    |    4 ++++
 packages/pnp4nagios/PNP4NAGIOS.hook      |   12 +++++++++---
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/packages/gearmand/GEARMAND_PORT.hook b/packages/gearmand/GEARMAND_PORT.hook
index 5cf789b..1c54fd3 100755
--- a/packages/gearmand/GEARMAND_PORT.hook
+++ b/packages/gearmand/GEARMAND_PORT.hook
@@ -15,6 +15,7 @@ case "$1" in
        echo "[a-zA-Z0-9\.\-]*:[1-9][0-9]{0,4}"
    ;;
    set)
+        mkdir -p $OMD_ROOT/etc/mod-gearman
         cat <<EOF > $OMD_ROOT/etc/mod-gearman/port.conf
 # sets the addess of your gearman job server. Please
 # change only by using the "omd config" command.
diff --git a/packages/mod-gearman/GEARMAN_WORKER.hook b/packages/mod-gearman/GEARMAN_WORKER.hook
index c8d8222..6a28fa3 100755
--- a/packages/mod-gearman/GEARMAN_WORKER.hook
+++ b/packages/mod-gearman/GEARMAN_WORKER.hook
@@ -18,6 +18,7 @@ case "$1" in
     set)
         if [ "$2" = "on" -o "$CONFIG_MOD_GEARMAN" = "on" ]; then
             # generate random key
+            mkdir -p $OMD_ROOT/etc/mod-gearman
             KEYSTORE="$OMD_ROOT/etc/mod-gearman/secret.key"
             if [ ! -s $KEYSTORE ]; then
                 key=`head -n 20 /dev/urandom | tr -d -c "[:alnum:]"`
diff --git a/packages/mod-gearman/MOD_GEARMAN.hook b/packages/mod-gearman/MOD_GEARMAN.hook
index 765d39b..fe37905 100755
--- a/packages/mod-gearman/MOD_GEARMAN.hook
+++ b/packages/mod-gearman/MOD_GEARMAN.hook
@@ -19,6 +19,10 @@ case "$1" in
     set)
         # this just enables/disables the gearman settings tree
         if [ "$2" = "on" ]; then
+            if [ ! -d $OMD_ROOT/etc/mod-gearman/. ]; then
+                echo "ERROR: make sure $OMD_ROOT/etc/mod-gearman exists! (Should have been shipped with OMD)"
+                exit 1
+            fi
             mkdir -p $OMD_ROOT/etc/nagios/nagios.d
             ln -sfn ../../mod-gearman/nagios.cfg $OMD_ROOT/etc/nagios/nagios.d/mod-gearman.cfg
         else
diff --git a/packages/pnp4nagios/PNP4NAGIOS.hook b/packages/pnp4nagios/PNP4NAGIOS.hook
index 96672a0..61b61f5 100755
--- a/packages/pnp4nagios/PNP4NAGIOS.hook
+++ b/packages/pnp4nagios/PNP4NAGIOS.hook
@@ -24,16 +24,22 @@ case "$1" in
            mkdir -p $OMD_ROOT/etc/nagios/nagios.d
            ln -sfn ../../pnp4nagios/nagios_npcdmod.cfg $OMD_ROOT/etc/nagios/nagios.d/pnp4nagios.cfg
            ln -sfn ../../pnp4nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/pnp4nagios.conf
-           sed -i -e 's/^perfdata=.*$/perfdata=no/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           if [ -s $OMD_ROOT/etc/mod-gearman/perfdata.conf ]; then
+               sed -i -e 's/^perfdata=.*$/perfdata=no/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           fi
        elif [ "$2" == "gearman" ]
        then
            ln -sfn ../../pnp4nagios/nagios_gearman.cfg $OMD_ROOT/etc/nagios/nagios.d/pnp4nagios.cfg
            ln -sfn ../../pnp4nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/pnp4nagios.conf
-           sed -i -e 's/^perfdata=.*$/perfdata=yes/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           if [ -s $OMD_ROOT/etc/mod-gearman/perfdata.conf ]; then
+               sed -i -e 's/^perfdata=.*$/perfdata=yes/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           fi
        else
            rm -f $OMD_ROOT/etc/nagios/nagios.d/pnp4nagios.cfg
            rm -f $OMD_ROOT/etc/apache/conf.d/pnp4nagios.conf
-           sed -i -e 's/^perfdata=.*$/perfdata=no/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           if [ -s $OMD_ROOT/etc/mod-gearman/perfdata.conf ]; then
+               sed -i -e 's/^perfdata=.*$/perfdata=no/' $OMD_ROOT/etc/mod-gearman/perfdata.conf
+           fi
        fi
    ;;
 



More information about the omd-commits mailing list