#!/bin/sh
#
# svxlink	This shell script takes care of starting and stopping
#		svxlink (The SvxLink server daemon).
#
# PROVIDE: svnserve
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable SVNServe:
#
#  svslink_enable="YES"
#  # optional
#  svnlink_flags=
#
# description: The SvxLink server is a multi purpose voice services system. \
# It is targeted at ham radio use. Connect the sound card to a radio \
# transceiver and load the modules you need. Enjoy...

# Source function library.
. /etc/rc.subr

name=svxlink
rcvar=`set_rcvar`

start_cmd=${name}_start
stop_cmd=${name}_stop

svxlink_enable=${svxlink_enable:-"NO"}
svxlink_flags=${svxlink_flags:-""}
svxlink_user=${svxlink_user:-"svxlink"}
svxlink_group=${svxlink_group:-"svxlink"}
svxlink_conf=${svxlink_conf:="/usr/local/etc/svxlink/svxlink.conf"}
svxlink_logfile=${svxlink_logfile:="/var/log/svslink"}
svxlink_pidfile=${svxlink-pidfil:="/var/run/svxlink.pid"}

#if [ -f /usr/local/etc/sysconfig/$PROG ];then
#        . /usr/local/etc/sysconfig/$PROG
#fi

start_remotetrx()
{
	if ! checkyesno svxlink_enable; then
		return;
	fi

	/usr/local/bin/$name --daemon --config=${svxlink_conf} \
		--pidfile=${svxlink_pidfile} --runasuser=${svxlink_user}
}

stop_remotetrx()
{
	if ! checkyesno svxlink_enable; then
		return;
	fi

	/bin/kill $(/bin/cat "${pidfile_svxlink}")
}

run_rc_command "$1"
