#!/bin/bash
#
# plusd    Starts and stops the BananaPOS plu server daemon.
#
# chkconfig: 2345 99 01
# description: plusd is the BananaPOS plu server daemon.
# processname: plusd
# pidfile: /var/run/plusd/plusd.pid
# config: /etc/plusd.conf

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /etc/plusd.conf ] || exit 0

[ -x /usr/sbin/plusd ] || exit 0

# See how we were called.
case "$1" in
start)
	echo -n "Starting plusd daemon: "
	if [ -f /var/run/plusd/plusd.pid ]; then
	    echo -n "removing mouldy old pid file"
	    rm -f /var/run/plusd/plusd.pid
	fi
	daemon plusd
	echo
	touch /var/lock/subsys/plusd
	;;
stop)
	echo -n "Shutting down plusd daemon: "
	killproc plusd
	echo
	rm -f /var/lock/subsys/plusd
	;;
status)
	status plusd
	;;
restart|reload)
	$0 stop
  	sleep 2
	$0 start
	;;
condrestart)
	[ -f /var/lock/subsys/plusd ] && restart
	;;
  *)
	echo "Usage: plusd {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit 0
