#!/bin/sh

# PROVIDE: mackerel_agent
# REQUIRE: NETWORKING SERVERS DAEMON
# KEYWORD: shutdown

# 
# Add the following lines to /etc/rc.conf to enable mackerel_agent:
# mackerel_agent_enable (bool) : Set to "NO" by default.
#                                Set it to "YES" to enable
# 

. /etc/rc.subr

name=mackerel_agent
rcvar=mackerel_agent_enable
load_rc_config ${name}

: ${mackerel_agent_enable:=NO}
: ${mackerel_agent_config:=%%ETCDIR%%/mackerel-agent.conf}

command="%%PREFIX%%/bin/mackerel-agent"
required_files="${mackerel_agent_config}"
command_args="supervise -conf ${mackerel_agent_config} ${mackerel_agent_flags}"

start_cmd=mackerel_agent_start

mackerel_agent_start()
{
	/usr/sbin/daemon -cf -S -T mackerel-agent ${command} ${command_args}
}

run_rc_command "$1"
