#!/bin/sh

# Init file for the oki4daemon printer driver daemon
#
# chkconfig: - 59 59
# description: A special daemon developed by Grant Taylor to \
#              support the OKI 4w and compatible winprinters. \
#              These printers have high requirements concerning \
#              timing and therefore one cannot use their driver \
#              directly out of a printer spooler (CUPS, LPD). To \
#              solve this problem, one lets the spooler send the \
#              job to this deamon. Activate this daemon when you \
#              have one of these printers and set up a CUPS queue \
#              for your printer with "oki4w_install". Do not \
#              connect an OKI winprinter to a machine with high \
#              loads or high security demands.
#
# processname: oki4daemon

WITHOUT_RC_COMPAT=1

. /etc/init.d/functions


RETVAL=0
LOCKFILE=/var/lock/subsys/oki4daemon
PIDFILE=/var/run/oki4daemon

start(){
	start_daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" -- oki4daemon
	RETVAL=$?
        return $RETVAL
}

stop(){
	stop_daemon --name oki4daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" -- oki4daemon
        RETVAL=$?
	return $RETVAL	
}

restart(){
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status --name oki4daemon --pidfile "$PIDFILE" -- oki4daemon
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
