#!/bin/sh
#
# sobexsrv  secure scripting obex server.
#
# chkconfig: 345 40 80
# description:	sobexsrv  is  a  Bluetooth  OBEX  server with \
#               Bluetooth Security Mode-2 (application triggered \
#               security) support.\
# processname: sobexsrv
# pidfile: /var/run/sobexsrv.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

LOCKFILE=/var/lock/subsys/sobexsrv
RETVAL=0

DAEMON_USER=sobexsrv
DAEMON=/usr/sbin/sobexsrv
DAEMON_OPTS="-IS -r /var/lib/sobexsrv/inbox -m /var/lib/sobexsrv/inbox/mime"

#Load configuration data
[ -e /ect/sysconfig/sobexsrv ] && . /etc/sysconfig/sobexsrv

if [ ! -z $SECURITY_LEVEL ]; then
    DAEMON_OPTS=" $DAEMON_OPTS -s $SECURITY_LEVEL"
fi

if [ ! -z $BIND_TO ]; then
    DAEMON_OPTS=" $DAEMON_OPTS -i $BIND_TO"
fi

if [ ! -z $LIST_OPTIONS ]; then
    DAEMON_OPTS=" $DAEMON_OPTS -l $LIST_OPTIONS"
fi
  
start()
{
    start_daemon --lockfile "$LOCKFILE" --user $DAEMON_USER -- $DAEMON $DAEMON_OPTS
    RETVAL=$?
    return $RETVAL
}

stop()
{
    stop_daemon --lockfile "$LOCKFILE" --expect-user $DAEMON_USER -- $DAEMON
    RETVAL=$?
    return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
    start)
            start
	    ;;
    stop)
            stop
	    ;;
    restart)
            restart
	    ;;
    condstop)
            if [ -e "$LOCKFILE" ]; then
                stop
	    fi
	    ;;
    condrestart)
            if [ -e "$LOCKFILE" ]; then
                restart
	    fi
	    ;;
    status)
	    status --lockfile "$LOCKFILE" --expect-user $DAEMON_USER -- $DAEMON
	    RETVAL=$?
	    ;;
    *)
            msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
	    RETVAL=1
esac

exit $RETVAL
