#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon

name=vnstat
description="Daemon based database updating for vnStat"

command=/usr/sbin/vnstatd
command_args="$VNSTATD_EXTRAOPTS"
command_args_foreground="--nodaemon"

command_user=vnstat:vnstat
supervise_daemon_args="--nicelevel  ${VNSTATD_NICELEVEL:-0}"

extra_started_commands="reload"

depend() {
	use net
}

pre_start() {
	checkpath -q -d -m 755 -o $command_user /var/lib/vnstat
}

reload() {
	ebegin "Reloading vnstatd configuration"
	$supervisor $RC_SVCNAME --signal HUP
	eend $?
}
