From: Dinko Korunic Date: Wed, 10 Oct 2007 15:00:20 +0000 (+0000) Subject: r8: - be able to reenable disabled services, too X-Git-Tag: v4.10.1-3~29 X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=commitdiff_plain;h=e29e5899e52aa4c37f9d31b91da48e26e76b3158;p=monit-cn.git r8: - be able to reenable disabled services, too --- 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