Monitoring-Generator-TestConfig

 view release on metacpan or  search on metacpan

lib/Monitoring/Generator/TestConfig/InitScriptData.pm  view on Meta::CPAN

killproc___LAYOUT__ () {
	kill $2 $PID

}


pid___LAYOUT__ () {
	if test ! -f $RunFile; then
		echo "No lock file found in $RunFile"
		exit 1
	fi

	PID=`head -n 1 $RunFile`
}


# Source function library
# Solaris doesn't have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
	. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
	. /etc/init.d/functions
fi

prefix=__PREFIX__
Bin=__BINARY__
CfgFile=${prefix}/__LAYOUT__.cfg
StatusFile=${prefix}/var/status.dat
RetentionFile=${prefix}/var/retention.dat
CommandFile=${prefix}/var/rw/__LAYOUT__.cmd
VarDir=${prefix}/var
RunFile=${prefix}/var/__LAYOUT__.pid
LockDir=${prefix}/var/
LockFile=__LAYOUT__.pid
User=__USER__
Group=__GROUP__


# Check that our binary exists.
if [ ! -f $Bin ]; then
    echo "Executable file $Bin not found.  Exiting."
    exit 1
fi

# Check that main configuration exists.
if [ ! -f $CfgFile ]; then
    echo "Configuration file $CfgFile not found.  Exiting."
    exit 1
fi

# See how we were called.
case "$1" in

	start)
		echo -n "Starting __LAYOUT__:"
		$Bin -v $CfgFile > /dev/null 2>&1;
		if [ $? -eq 0 ]; then
			touch $VarDir/__LAYOUT__.log $RetentionFile
			rm -f $CommandFile
			touch $RunFile
			#chown $User:$Group $RunFile
			$Bin -d $CfgFile
			if [ -d $LockDir ]; then touch $LockDir/$LockFile; fi
			echo " done."
			exit 0
		else
			echo "CONFIG ERROR!  Start aborted.  Check your configuration."
			exit 1
		fi
		;;

	stop)
		echo -n "Stopping __LAYOUT__: "

		pid___LAYOUT__
		killproc___LAYOUT__ $Bin

 		# now we have to wait for the process to exit and remove its
 		# own RunFile, otherwise a following "start" could
 		# happen, and then the exiting process will remove the
 		# new RunFile, allowing multiple daemons
 		# to (sooner or later) run - John Sellens
		#echo -n 'Waiting for __LAYOUT__ to exit .'
 		for i in 1 2 3 4 5 6 7 8 9 10 ; do
 		    if status___LAYOUT__ > /dev/null; then
 			echo -n '.'
 			sleep 1
 		    else
 			break
 		    fi
 		done
 		if status___LAYOUT__ > /dev/null; then
 		    echo ''
 		    echo 'Warning - __LAYOUT__ did not exit in a timely manner'
 		else
 		    echo 'done.'
 		fi

		rm -f $StatusFile $RunFile $LockDir/$LockFile $CommandFile
		;;

	status)
		pid___LAYOUT__
		printstatus___LAYOUT__ $Bin
		;;

	check|checkconfig)
		printf "Running configuration check..."
		$Bin -v $CfgFile
		if [ $? -eq 0 ]; then
			echo " OK."
		else
			echo " CONFIG ERROR!  Check your __LAYOUT__ configuration."
			exit 1
		fi
		;;

	restart)
		printf "Running configuration check..."
		$Bin -v $CfgFile > /dev/null 2>&1;
		if [ $? -eq 0 ]; then



( run in 1.113 second using v1.01-cache-2.11-cpan-71847e10f99 )