#!/bin/sh
#
# remotetrx	This shell script takes care of starting and stopping
#		remotetrx (The SvxLink remote transceiver daemon).
#

# PROVIDE: remotetrx
# REQUIRE: NETWORKING DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable remotetrx:
#
#  remotetrx_enable="YES"
#  # optional
#  remotetrx_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=remotetrx
rcvar=`set_rcvar`

#start_remotetrx=start_remotetrx
#stop_remotetrx=stop_remotetrx

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

remotetrx_enable=${remotetrx_enable:-"NO"}
remotetrx_flags=${remotetrx_flags:-""}
remotetrx_user=${svxlink_user:-"svxlink"}
remotetrx_group=${svxlink_group:-"svxlink"}
remotetrx_conf=${svxlink_conf:="/usr/local/etc/svxlink/remotetrx.conf"}
remotetrx_logfile=${remotetrx_logfile:="/var/log/remotetrx"}
remotetrx_pidfile=${remotetrx_pidfile:="/var/run/remotetrx.pid"}

#[--help] [--daemon] [--logfile=log file] [--config=configura-
#       tion file] [--pidfile=pid file] [--runasuser=user name]


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

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

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

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

run_rc_command "$1"
