From 90c7a7d4d71ac3470b93977c00b6cfa0a4fae7c1 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 29 Apr 2013 12:06:04 -0300 Subject: Improvements on unbound_monitor.sh - Use internal true since there is no /bin/true - Avoid have multiple instances running - Teach it how to stop --- config/unbound/unbound_monitor.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'config/unbound') diff --git a/config/unbound/unbound_monitor.sh b/config/unbound/unbound_monitor.sh index 23939311..95cc73f8 100755 --- a/config/unbound/unbound_monitor.sh +++ b/config/unbound/unbound_monitor.sh @@ -35,10 +35,23 @@ if [ -f /var/run/unbound_alarm ]; then rm /var/run/unbound_alarm fi + +if [ "$1" = "stop" ]; then + pkill -f unbound_monitor.sh + exit 0 +fi + +PROCS=`/bin/pgrep -f unbound_monitor.sh | wc -l | awk '{print $1}'` + +if [ ${PROCS} -gt 2 ]; then + echo "There are another unbound monitor proccess running" + exit 0 +fi + # Sleep 5 seconds on startup not to mangle with existing boot scripts. sleep 5 -while [ /bin/true ]; do +while true; do if [ ! -f /var/run/unbound_alarm ]; then NUM_PROCS=`/bin/pgrep unbound | wc -l | awk '{print $1}'` if [ $NUM_PROCS -lt 1 ]; then -- cgit v1.2.3