#!/bin/sh
#
# name:        /etc/rc.d/nrserver.sh
# description: Starts and stops NeoRouter connection server
# os:          FreeBSD
# contact:     support@neorouter.com 
#
# PROVIDE: nrserver
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="nrserver"
rcvar=`set_rcvar`
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/${name}.pid"
required_files="/usr/local/ZebraNetworkSystems/NeoRouter/server.crt /usr/local/ZebraNetworkSystems/NeoRouter/server.key"
DAEMON="/usr/local/bin/${name}"

nrserver_start() 
{
	echo -n "Starting ${name} services: "
	/usr/sbin/daemon -f -p $pidfile $DAEMON >/dev/null &
	if [ $? -eq 0 ]
	then
	    echo "SUCCESS"
	else
	    echo "FAILED"
	fi
}	

nrserver_stop() 
{
	echo -n "Shutting down ${name} services: "
	pkill $name
	if [ $? -eq 0 ]
	then
	    echo "SUCCESS"
	else
	    echo "FAILED"
	fi
}	

load_rc_config $name
run_rc_command "$1"

