#!/sbin/openrc-run

name="ipfixprobe"
description="High-performance flow exporter"

if ! [ "${cfgname-}" ]; then
	cfgname="${RC_SVCNAME#ipfixprobe.}"
	[ "$cfgname" = 'ipfixprobe' ] && cfgname="link0"
fi
: ${capabilities="^cap_net_raw,^cap_ipc_lock"}
: ${command_user:="ipfixprobe:ipfixprobe"}
: ${error_logger="logger -t ipfixprobe -p daemon.info >/dev/null 2>&1"}

command="/usr/bin/ipfixprobed"
command_args="$cfgname $command_args"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

required_files="/etc/ipfixprobe/$cfgname.conf"

depend() {
	need net
	after firewall
}

start_pre() {
	# Legacy from ipfixprobe 4.x.
	if [ "${input-}${output-}${process-}${storage-}" ]; then
		eerror "Configuration using input, output, ... variables in conf.d file is not supported"
		eerror "anymore, use the new YAML-based configuration."
		return 1
	fi
}
