#!/bin/sh

# $FreeBSD$
#
# PROVIDE: litecoin
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# litecoin_enable (bool):	Set to NO by default.
#				Set it to YES to enable litecoin.
# litecoin_config (path):	Set to /usr/local/etc/litecoin.conf
#				by default.

. /etc/rc.subr

name=litecoin
rcvar=`set_rcvar`

load_rc_config $name

: ${litecoin_enable:="NO"}
: ${litecoin_config="/usr/local/etc/litecoin.conf"}

command=/usr/local/bin/litecoind
datadir=/var/db/litecoin
pidfile="${datadir}/litecoind.pid"
stop_cmd="litecoin_stop"
command_args="-conf=${litecoin_config} -datadir=${datadir} -noupnp -daemon"

litecoin_stop()
{
    if checkyesno ${rcvar}; then
	echo "Stopping ${name}."
      $command -conf=${litecoin_config} -datadir=${datadir} stop
	wait_for_pids ${pidfile}
    fi
}

run_rc_command "$1"
