#!/sbin/runscript
#
# Run script for Gentoo /etc/init.d
# Package net-voip/yate

extra_started_commands="reload"

description="Starts and stops YATE used as Telephony Server"

depend() {
	need net
	use mysql postgresql wanpipe zaptel
}

OPTS=${OPTS:- -F -s -r -l /var/log/yate -vvv -Df}
PIDFILE=${PIDFILE:-/var/run/${SVCNAME}.pid}
BINARY=${BINARY:-/usr/bin/yate}

start() {
	ebegin "Starting ${SVCNAME}"
	export PWLIB_ASSERT_ACTION=C
	start-stop-daemon --start --exec "${BINARY}" \
	    --pidfile "${PIDFILE}" -- \
	    -d -p "${PIDFILE}" ${OPTS}
	eend $?
}

stop() {
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --pidfile "${PIDFILE}" --quiet
	eend $?
}

reload() {
	ebegin "Reloading ${SVCNAME}"
	start-stop-daemon --stop --signal HUP --oknodo --pidfile "${PIDFILE}"
	eend $?
}
