X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=monit-cn.git;a=blobdiff_plain;f=update-monit.d;h=05472e9342d5e7add1f195932678e3679e695f0a;hp=4ed19e1ef3b2ce152075bb62a5050091a040a0db;hb=007a5f05615fb2be7823645ec159c980da1a89fc;hpb=e29e5899e52aa4c37f9d31b91da48e26e76b3158 diff --git a/update-monit.d b/update-monit.d index 4ed19e1..05472e9 100755 --- a/update-monit.d +++ b/update-monit.d @@ -1,4 +1,11 @@ #!/bin/sh +# +# Copyright (C) 2007 Dinko Korunic, CARNet, Grupa za izradu paketa +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. MONIT_DIR=/etc/monit.d TEMPLATES_DIR=/usr/share/monit-cn @@ -12,13 +19,26 @@ check_service() { return 1 fi - script='BEGIN { RS = "[ \t\n]+" } + scriptpid='BEGIN { RS = "[ \t\n]+" } { line[NR] = $0 "" } END { for (j in line) if (line[j] == "pidfile") print line[j + 1] }' - pidfiles=$(awk "$script" < "$filename" | sed -e 's/"//g') + pidfiles=$(awk "$scriptpid" < "$filename" | sed -e 's/"//g') check_pidfile $pidfiles + + if [ $RET -eq 1 ]; then + return 1 + fi + + scriptinit='BEGIN { RS = "[ \t\n]+" } + { line[NR] = $0 "" } + END { for (j in line) + if (((line[j] == "start") || (line[j] == "stop")) && (line[j + 1] == "program")) + print line[j + 3] }' + initscripts=$(awk "$scriptinit" < "$filename" | sed -e 's/"//g') + check_initscript $initscripts + return $RET } @@ -41,6 +61,20 @@ check_pidfile() { return 0 } +check_initscript() { + RET=0 + + while [ -n "$1" ]; do + if [ ! -x "$1" ]; then + RET=1 + return 1 + fi + shift + done + + return 0 +} + check_pid() { RET=0