#! /bin/sh
### BEGIN INIT INFO
# Provides:          OPPD
# Required-Start:    $syslog
# Should-Start:
# Required-Stop:     $syslog
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Startup/shutdown script for the oppd (OpenPrinting Japan StatusDaemon)
# Description:       Startup/shutdown script for the oppd (OpenPrinting Japan StatusDaemon)
### END INIT INFO

OPPD_DAEMON=/usr/sbin/oppd-listen
OPPD_CONFIG=/etc/oppd.conf
OPPD_LOCK=/var/lock/subsys/oppd

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x ${OPPD_DAEMON} || { echo "${OPPD_DAEMON} not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

# Check for existence of needed config file and read it
test -r ${OPPD_CONFIG} || { echo "${OPPD_CONFIG} not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
	echo -n "Starting OPPD "
	startproc ${OPPD_DAEMON} > /dev/null 2>&1 &
	rc_status -v
	;;
    stop)
	echo -n "Shutting down OPPD "
	killproc -TERM ${OPPD_DAEMON}
	rc_status -v
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    reload)
	echo -n "Reload service OPPD "
	killproc -HUP ${OPPD_DAEMON}
	rc_status -v
	;;
    status)
	echo -n "Checking for service OPPD "
	checkproc ${OPPD_DAEMON}
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac
rc_exit
