#!/bin/bash
#
# soundmodem        Startup script for the AX.25 Soundmodem
#
# chkconfig: - 55 50
# description: Soundmodem provides the APRS AX.25 Port.
# processname: soundmode
# config: /etc/ax25/soundmodem.conf
# pidfile: /var/run/soundmodem.pid
#
# Author: Graham Auld aprs@graham.auld.me.uk 15th Jan 2007

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


# Path to the sound modem executable and other bits.
soundmodem=/usr/local/sbin/soundmodem
prog=soundmodem
pidfile=/var/run/$prog.pid
lockfile=/var/lock/subsys/$prog
RETVAL=0

start() {
        echo -n $"Starting $prog: "
	daemon "$soundmodem -s -v 0 >/dev/null 2>/dev/null &"
        RETVAL=$?
	echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
	echo -n $"Stopping $prog: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
#see how we were called
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        tail $logfile
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f ${pidfile} ] ; then
		stop
		start
	fi
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|status|}"
	exit 1
esac

exit $RETVAL