#!/bin/sh
#
# This is file is either 
#
#         /etc/rc.d/init.d/junkbuster 
#
# or
#
#         /sbin/init.d/junkbuster
#
# and was put here by the junkbuster rpm
#
# junkbuster  This shell script takes care of starting and stopping
#             junkbuster.
#
#
# SuSE's version with help by Mark Lutz <luma@nikocity.de>
#

# Source function library.
# For RedHat only
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

# For SuSE only
if [ -f /etc/rc.config ]; then
. /etc/rc.config
fi

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

# See how we were called.
case "$1" in
	start)
	        # abort if already started
                [ -f /var/lock/subsys/junkbuster ] && echo -e "$return" && exit 0 
		# Start daemon.
                echo -n "Starting junkbuster:"
		su - nobody -c '/usr/sbin/junkbuster /etc/junkbuster/config' &
		touch /var/lock/subsys/junkbuster
		sleep 1
                echo -e "$return"
		;;
	stop)
		# Stop daemon.
		echo -n "Shutting down junkbuster:"
		# For SuSE only
		if [ -f /etc/rc.config ]; then
		    killproc -TERM /usr/sbin/junkbuster || return=\$rc_failed
		else
		    killproc junkbuster || return=$rc_failed
		fi
		rm -f /var/lock/subsys/junkbuster
                echo -e "$return"
		;;
	status)
		# For SuSE only
		if [ -f /etc/rc.config ]; then
		    checkproc /usr/sbin/junkbuster && echo OK || echo No process
		fi
		;;
	restart|reload)
                $0 stop  &&  $0 start  ||  return=$rc_failed
		;;
	*)
		echo "Usage: junkbuster {start|stop|status|restart|reload}"
		exit 1
esac

# Inform the caller not only verbosely and set an exit status.
test "$return" = "$rc_done" || exit 1

exit 0
