#!/bin/sh
#
# /etc/init.d/TaniumClient
# Subsystem file for "TaniumClient" service
#
# chkconfig: 2345 95 05
# description: TaniumClient daemon
#
# processname: TaniumClient
# config: /etc/sysconfig/TaniumClient
# pidfile: /var/run/TaniumClient.pid

# source function library
. /etc/rc.d/init.d/functions

# pull in sysconfig settings
[ -f /etc/sysconfig/TaniumClient ] && . /etc/sysconfig/TaniumClient

RETVAL=0
prog="TaniumClient"

start() {
	echo -n "Starting $prog:"
	daemon RPM_INSTALL_PREFIX/Tanium/TaniumClient/TaniumClient
	RETVAL=$?
	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/$prog
	echo
	return $RETVAL
}

stop() {
	echo -n "Stopping $prog:"
	killproc $prog -TERM
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/$prog
	echo
	return $RETVAL
}

case "$1" in
	start)
		start
		RETVAL=$?
		;;
	stop)
		stop
		RETVAL=$?
		;;
	restart)
		stop
		sleep 3
		start
		RETVAL=$?
		;;
	condrestart)
		if [ -f /var/lock/subsys/$prog ] ; then
			stop
			# avoid race
			sleep 3
			start
			RETVAL=$?
		fi
		;;
	status)
		status $prog
		RETVAL=$?
		;;
	*)
		echo "Usage: $0 {start|stop|restart|condrestart|status}"
		RETVAL=1
esac
exit $RETVAL

