From e29e5899e52aa4c37f9d31b91da48e26e76b3158 Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Wed, 10 Oct 2007 15:00:20 +0000 Subject: [PATCH] r8: - be able to reenable disabled services, too --- update-monit.d | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/update-monit.d b/update-monit.d index 789efff..4ed19e1 100755 --- a/update-monit.d +++ b/update-monit.d @@ -60,26 +60,38 @@ check_pid() { changed=0 if [ ! -d "$MONIT_DIR" ]; then mkdir -p "$MONIT_DIR" -else - for i in $(find "$MONIT_DIR" -name '*.conf'); do - check_service $i - if [ ! $RET -eq 0 ]; then - serviceconf=$(basename $i) - echo "CN: Disabled $serviceconf" - mv -f $i $i.disabled - changed=1 - fi - done fi -for i in $(find "$TEMPLATES_DIR" -name '*.conf'); do +for i in $(find "$MONIT_DIR" -name '*.conf'); do check_service $i - if [ $RET -eq 0 ]; then + if [ ! $RET -eq 0 ]; then serviceconf=$(basename $i) - if [ ! -r "$MONIT_DIR"/$serviceconf ]; then - echo "CN: Enabled $serviceconf" - cp -a $i "$MONIT_DIR" - changed=1 + echo "CN: Disabled $serviceconf" + mv -f $i $i.disabled + changed=1 + fi +done + +for i in $(find "$TEMPLATES_DIR" -name '*.conf'); do + serviceconf=$(basename $i) + if [ -r "$MONIT_DIR"/$serviceconf.disabled ]; then + check_service "$MONIT_DIR"/$serviceconf.disabled + if [ $RET -eq 0 ]; then + if [ ! -r "$MONIT_DIR"/$serviceconf ]; then + echo "CN: Enabled $serviceconf (previously disabled)" + mv "$MONIT_DIR"/$serviceconf.disabled \ + "$MONIT_DIR"/$serviceconf + changed=1 + fi + fi + else + check_service $i + if [ $RET -eq 0 ]; then + if [ ! -r "$MONIT_DIR"/$serviceconf ]; then + echo "CN: Enabled $serviceconf (new service)" + cp -a $i "$MONIT_DIR" + changed=1 + fi fi fi done -- 1.7.10.4