#!/bin/sh
#
# pand	Bluetooth Personal Area Networking Daemon
#
# chkconfig:	345 26 89
#
# description:	Bluetooth Personal Area Networking Daemon. Provides network services over Bluetooth.
#
# $Id: pand.init,v 1.3 2011/09/11 19:35:28 glen Exp $


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

. /etc/sysconfig/network

[ -f /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth

is_no "${NETWORKING}" && exit 0

start() {
	# Check if the service is already running?
	if [ -f /var/lock/subsys/pand ]; then
		msg_already_running pand
		return
	fi

	msg_starting pand
	daemon /usr/bin/pand ${PAND_OPTIONS}
	RETVAL=$?
	touch /var/lock/subsys/pand
}

stop() {
	if [ ! -f /var/lock/subsys/pand ]; then
		msg_not_running pand
		return
	fi

	msg_stopping pand
	killproc /usr/bin/pand
	rm -f /var/lock/subsys/pand
}

condrestart() {
	if [ ! -f /var/lock/subsys/pand ]; then
		msg_not_running pand
		RETVAL=$1
		return
	fi

	stop
	start
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload|force-reload)
	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  status)
	status pand
	if [ -f /var/lock/subsys/pand ]; then
		nls "pand is running"
		exit 0
	else
		msg_not_running pand
		exit 3
	fi
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
	exit 3
esac

exit $RETVAL
