#!/sbin/openrc-run

name=supernode
description="N2N Supernode Daemon"

instance=${RC_SVCNAME##*.}
[ -n "$instance" ] && : ${cfgfile:=/etc/n2n/supernode-$instance.conf}
: ${cfgfile:=/etc/n2n/supernode.conf}

command="/usr/sbin/supernode"
command_args="$cfgfile ${command_opts}"
supervisor="supervise-daemon"

pidfile="/run/$name.pid"
output_log="/var/log/${RC_SVCNAME}.log"
error_log="/var/log/${RC_SVCNAME}.log"

retry="${SUPERNODE_RETRY:-TERM/60/KILL/10}"

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -f -m 0644 -o "$command_user" "$output_log" "$error_log"
	checkpath -f -m 0640 -o "$command_user" "$cfgfile"
}
