#!/bin/sh

# PROVIDE: go-cve-dictionary
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# go_cve_dictionary_enable (bool):     Set to NO by default
#                                      Set it to YES to enable the CVE server
# go_cve_dictionary_user (string):     Set user to run go_cve_dictionary
#                                      Default is "vuls"
# go_cve_dictionary_group (string):    Set group to run go_cve_dictionary
#                                      Default is "vuls"
# go_cve_dictionary_log_file (string): Set file that go-cve-dictionary will log to
#                                      Default is "/var/log/vuls/go_cve_dictionary.log"
# go_cve_dictionary_args (string):     Set additional command line arguments
#                                      Default is ""
#
# Set up go-cve-dictionary using the config file: /usr/local/etc/go-cve-dictionary.yaml
#

. /etc/rc.subr

name=go_cve_dictionary
rcvar=go_cve_dictionary_enable

load_rc_config $name

: ${go_cve_dictionary_enable:="NO"}
: ${go_cve_dictionary_user:="vuls"}
: ${go_cve_dictionary_group:="vuls"}
: ${go_cve_dictionary_log_file:="/var/log/vuls/go_cve_dictionary.log"}
: ${go_cve_dictionary_args:=""}

pidfile=/var/run/${name}.pid
pidfile_daemon=/var/run/${name}_daemon.pid
command="/usr/sbin/daemon"
procname="/usr/local/bin/go-cve-dictionary"

command_args="-p ${pidfile} -P ${pidfile_daemon} -t ${name} \
	-Ho ${go_cve_dictionary_log_file} \
	${procname} server \
	${go_cve_dictionary_args}"

start_precmd=go_cve_dictionary_startprecmd

go_cve_dictionary_startprecmd()
{
	/usr/bin/install -o ${go_cve_dictionary_user} -g ${go_cve_dictionary_group} \
		-m 640 /dev/null ${pidfile}
	/usr/bin/install -o ${go_cve_dictionary_user} -g ${go_cve_dictionary_group} \
		-m 640 /dev/null ${pidfile_daemon}
}

load_rc_config $name
run_rc_command "$1"
