#!/bin/sh
#
# This is file /etc/rc.d/init.d/junkbuster and was put here 
# by the junkbuster rpm
#
# chkconfig: 235 84 09
#
# junkbuster  This shell script takes care of starting and stopping
#             junkbuster.
#

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

[ -f /usr/sbin/junkbuster ] || exit 0

# See how we were called.
case "$1" in
	start)
	        # abort if already started
                [ -f /var/lock/subsys/junkbuster ] && exit 0 

		# Start daemon.
		#
		# This works only correctly if the user `junkbust' is allowed
		# to be in the directory where this file is called 
		# (for example: /root is NOT ok)
		# 
                echo -n "Starting junkbuster:  "
	        su -l junkbust -c "/usr/sbin/junkbuster /etc/junkbuster/config &"
		touch /var/lock/subsys/junkbuster

		echo junkbuster
		;;

	stop)
		# Stop daemon.
		echo -n "Shutting down junkbuster:  "
		killproc junkbuster
		rm -f /var/lock/subsys/junkbuster
		echo junkbuster
		;;

	restart)
		$0 stop
		$0 start
		;;

	*)
		echo "Usage: junkbuster {start|stop|restart}"
		exit 1
esac

exit 0
