#!/sbin/openrc-run
# The visthus package ships this script, not Alpine's from nebula-openrc: that one logs to /var/log on the OS partition, where the
# log would grow without limit. supervise-daemon pipes Nebula's output to syslog, which keeps it in memory.
command=/usr/sbin/nebula
command_args="-config /etc/nebula/config.yml"
command_user=nebula
supervisor=supervise-daemon
capabilities="^cap_net_admin"
output_logger="logger -t nebula -p daemon.info"
error_logger="logger -t nebula -p daemon.err"

depend() {
	need net
	use logger
}

# nebula -test prints the whole config, so show what it printed only when the test fails.
start_pre() {
	local out
	out=$($command $command_args -test 2>&1) || { eerror "$out"; return 1; }
}
