#!/bin/bash
#
# ssbd.init for version 0.10.  starts or stops ssbd.
# This file should be placed in /etc/rc.d/init.d/
#
# chkconfig: - 60 50
# description: sbd is a daemon for SSB voice keying and audio recording for Tucnak
# processname: ssbd
# config: /etc/sysconf/ssbd

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

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

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

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

# Source cwdaemon configuration.
[ -r /etc/sysconfig/ssbd ] && . /etc/sysconfig/ssbd

RETVAL=0
prog="ssbd"

start() {
        # Start daemons.
        echo -n $"Starting $prog: "
        daemon /usr/sbin/ssbd $OPTS
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ssbd
        echo
        return $RETVAL
}

stop() {
        # Stop daemons.
        echo -n $"Shutting down $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ssbd
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/ssbd ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL
