Blob Blame History Raw
diff -up ./startup/default-init.in.fix_el6_init ./startup/default-init.in
--- ./startup/default-init.in.fix_el6_init	2019-01-15 09:58:00.000000000 -0500
+++ ./startup/default-init.in	2019-02-05 09:38:09.463144849 -0500
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# chkconfig: 345 99 01
+# chkconfig: - 99 01
 # description: Nagios network monitor
 # processname: nagios
 # File : nagios
@@ -24,6 +24,9 @@
 #  - Clean out redhat macros and other dependencies
 # 2003-01-11 Ethan Galstad <egalstad@nagios.org>
 #  - Updated su syntax (Gary Miller)
+# 2018-11-28 Justin Paulsen <petaris@gmail.com>
+#  - Patched for EPEL release of Nagioscore 4.4.2
+#  - - nagios-0001-default-init.patch
 #
 # Description: Starts and stops the Nagios monitor
 #              used to provide network services status.
@@ -91,12 +94,12 @@ check_config ()
 		echo "ERROR: Could not delete '$NagiosCfgtestFile'"
 		exit 8
 	fi
-	if ! su $NagiosUser -c "touch $NagiosCfgtestFile"; then
+	if ! su $NagiosUser -c "touch $NagiosCfgtestFile" -s /bin/sh ; then
 		echo "ERROR: Could not create or update '$NagiosCfgtestFile'"
 		exit 8
 	fi
 
-	TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX)
+	TMPFILE=$(mktemp $NagiosCfgtestFile.XXX)
 	$NagiosBin -vp $NagiosCfgFile > "$TMPFILE"
 	WARN=`grep ^"Total Warnings:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
 	ERR=`grep ^"Total Errors:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
@@ -138,11 +141,14 @@ status_nagios ()
 
 printstatus_nagios ()
 {
-	if status_nagios; then
+	status_nagios $1 $2
+	RETVAL=$?
+	if [ $RETVAL = 0 ]; then
 		echo "nagios (pid $NagiosPID) is running..."
 	else
 		echo "nagios is not running"
 	fi
+	return $RETVAL
 }
 
 killproc_nagios ()
@@ -157,7 +163,17 @@ pid_nagios ()
 		return 1
 	fi
 
-	NagiosPID=`head -n 1 $NagiosRunFile`
+	export NagiosPID=`head -n 1 $NagiosRunFile`
+	if [[ -z "$NagiosPID" ]]; then
+	    echo "No usable PID found in $NagiosRunFile"
+	    exit 1
+	fi
+	
+	regex='^[0-9]+$'
+	if ! [[ $NagiosPID =~ $regex ]]; then
+	    echo "PID not number found in $NagiosRunFile"
+	    exit 1
+	fi
 }
 
 # Check that nagios exists.
@@ -188,7 +204,7 @@ case "$1" in
 			fi
 		fi
 
-		su $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
+		su $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile" -s /bin/sh
 		@BIN_RM@ -f $NagiosCommandFile
 		touch $NagiosRunFile
 		$NagiosBin -d $NagiosCfgFile
@@ -281,6 +297,7 @@ case "$1" in
 	*)
 		echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig|configtest}"
 		exit 1
+		exit 2
 		;;
 
 esac