#!/bin/sh

# PROVIDE: zm_testagent
# REQUIRE: NETWORKING mysql postgresql
# KEYWORD: shutdown

. /etc/rc.subr

name="zm_testagent"
rcvar="${name}_enable"

load_rc_config $name
: ${zm_testagent_enable="NO"}
: ${zm_testagent_user="zonemaster"}
: ${zm_testagent_group="zonemaster"}
: ${zm_testagent_pidfile="/var/run/zonemaster/${name}.pid"}

export ZONEMASTER_BACKEND_CONFIG_FILE="/usr/local/etc/zonemaster/backend_config.ini"
#ZM_BACKEND_TESTAGENT_LOGLEVEL='info'  # Set this variable to override the default log level

# Make Perl available for service() when executed via env() in script
export PATH="$PATH:/usr/local/bin"

command="/usr/local/bin/zonemaster_backend_testagent"
command_args="--user=${zm_testagent_user} --group=${zm_testagent_group} --pidfile=${zm_testagent_pidfile}"
if [ -n "$ZM_BACKEND_TESTAGENT_LOGLEVEL" ] ; then
    command_args="$testagent_args --loglevel=$ZM_BACKEND_TESTAGENT_LOGLEVEL"
fi
pidfile="${zm_testagent_pidfile}"
procname="/usr/local/bin/perl"
required_files="/usr/local/etc/zonemaster/backend_config.ini"

start_precmd="${name}_prestart"
stop_precmd="${name}_prestop"

zm_testagent_prestart()
{
    rc_flags="${rc_flags} start"
}

zm_testagent_prestop()
{
    rc_flags="${rc_flags} stop"
}

run_rc_command "$1"
