#!/bin/sh -
# Copyright (c) 2015 Johannes Meixner

# PROVIDE: opentsdb
# REQUIRE: LOGIN
# KEYWORD: shutdown
# opentsdb_enable (bool):        Set to NO by default.
#                                Set it to YES to enable OpenTSDB

. /etc/rc.subr

export PATH=${PATH}:%%PREFIX%%/bin

name=opentsdb
rcvar=opentsdb_enable

load_rc_config "${name}"

: ${opentsdb_enable:=NO}
: ${opentsdb_user:=opentsdb}
: ${opentsdb_jvmargs:=-enableassertions -enablesystemassertions}
: ${opentsdb_opts:=tsd 2> %%OPENTSDB_LOGDIR%%/error.log 1> %%OPENTSDB_LOGDIR%%/tsdb.log}

pidfile="%%OPENTSDB_RUNDIR%%/${name}.pid"
opentsdb_daemon="%%PREFIX%%/bin/tsdb"
procname="daemon*"

command="/usr/sbin/daemon"
command_args="-P ${pidfile} ${opentsdb_daemon} ${opentsdb_opts}"

export JVMARGS=${opentsdb_jvmargs}

run_rc_command "$1"
