#! /bin/sh
#
# baycomusb     Start Baycom USB driver.
#
# Author:       Thomas Sailer, <sailer@ife.ee.ethz.ch>
#
# chkconfig: 345 50 50
# description: Baycom USB daemon
# processname: baycomusbserv
# pidfile: /var/run/baycomusb.pid

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

# Get config.
. /etc/sysconfig/network

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

[ -f /usr/sbin/baycomusbserv ] || exit 0

RETVAL=0

function start()
{
	rm -f /var/hamradio/transceivers/*
	#/sbin/modprobe baycom_usb
        echo -n "Starting baycomusbserv:"
        daemon /usr/sbin/baycomusbserv -d -ORBIIOPIPv4=0 -ORBIIOPIPv6=0
        RETVAL=$?
        echo
        [ "$RETVAL" = 0 ] && touch /var/lock/subsys/baycomusb
}

function stop()
{
        echo -n "Stopping baycomusbserv:"
        killproc /usr/sbin/baycomusbserv
        RETVAL=$?
        echo
        [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/baycomusb
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f /var/lock/subsys/baycomusb ] ; then
                stop
                start
        fi
        ;;
  status)
        status /usr/sbin/baycomusbserv
        ;;
  *)
        echo "Usage: baycomusb {start|stop|restart|condrestart|status}"
        RETVAL=1
esac
exit $RETVAL
