[icinga-checkins] icinga.org: icinga-core/rdarrud/cgis: move start to a separate function to fix #636

git at icinga.org git at icinga.org
Thu Sep 16 21:46:42 CEST 2010


Module: icinga-core
Branch: rdarrud/cgis
Commit: 50adc25ce997ab12990c130ebcf460224455b688
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=50adc25ce997ab12990c130ebcf460224455b688

Author: Christoph Maser <cmr at financial.com>
Date:   Sat Jul 24 22:34:34 2010 +0200

move start to a separate function to fix #636

---

 daemon-init.in |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/daemon-init.in b/daemon-init.in
index 4439ccc..3204dda 100644
--- a/daemon-init.in
+++ b/daemon-init.in
@@ -94,7 +94,7 @@ pid_icinga ()
 
 chk_config ()
 {
-	echo "Running configuration check..."
+	echo -n "Running configuration check..."
 	$IcingaBin -v $IcingaCfgFile > $IcingaChkFile 2>&1
 	if test $? -ne 0; then
 		if test -z "$1"; then
@@ -146,34 +146,39 @@ if [ ! -f $IcingaCfgFile ]; then
     echo "Configuration file $IcingaCfgFile not found.  Exiting."
     exit 1
 fi
-          
-# See how we were called.
-case "$1" in
 
-	start)
-		# Check if icinga is already running
-	        $0 status > /dev/null
-                if [ $? -eq 0 ]; then
-                        pid_icinga
-			# check if pid can be found running
-			if status_icinga > /dev/null; then
-	                        echo "Icinga is already running. PID: $IcingaPID"
+start(){
+	# Check if icinga is already running
+	$0 status > /dev/null
+	if [ $? -eq 0 ]; then
+		pid_icinga
+		# check if pid can be found running
+		if status_icinga > /dev/null; then
+			echo "Icinga is already running. PID: $IcingaPID"
 				exit 1
 			else
 				echo "Icinga PID $IcingaPID not running. Removing lockfile."
 				rm -f $IcingaStatusFile $IcingaRunFile $IcingaLockDir/$IcingaLockFile $IcingaCommandFile
-			fi
-                fi
+		fi
+	fi
+
+	echo -n "Starting icinga: "
+	rm -f $IcingaCommandFile
+	touch $IcingaRunFile
+	chown $IcingaUser:$IcingaGroup $IcingaRunFile
+	$IcingaBin -d $IcingaCfgFile
+	if [ -d $IcingaLockDir ]; then touch $IcingaLockDir/$IcingaLockFile; fi
+	echo "Starting icinga done."
+	exit 0
+
+}
+          
+# See how we were called.
+case "$1" in
 
-		echo -n "Starting icinga: "
+	start)
 		chk_config "CONFIG ERROR!  Start aborted. See $IcingaChkFile for details."
-		rm -f $IcingaCommandFile
-		touch $IcingaRunFile
-		chown $IcingaUser:$IcingaGroup $IcingaRunFile
-		$IcingaBin -d $IcingaCfgFile
-		if [ -d $IcingaLockDir ]; then touch $IcingaLockDir/$IcingaLockFile; fi
-		echo "Starting icinga done."
-		exit 0
+		start
 		;;
 
 	stop)
@@ -222,7 +227,7 @@ case "$1" in
 	restart)
 		chk_config " CONFIG ERROR!  Restart aborted.  See $IcingaChkFile for details."
 		$0 stop
-		$0 start
+		start
 		;;
 
 	reload|force-reload)





More information about the icinga-checkins mailing list