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

opts="${opts} reload"

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

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

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

start() {
	ebegin "Starting ${SVCNAME}"
	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 $?
}
