#!/sbin/runscript # Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 # $Id$ WEBRTC_NAME=${SVCNAME##*.} if [ -n "${WEBRTC_NAME}" -a "${SVCNAME}" != "spreed-webrtc" ]; then WEBRTC_PID="/var/run/spreed-webrtc.${WEBRTC_NAME}.pid" WEBRTC_CONF_DEFAULT="/etc/spreed-webrtc/${WEBRTC_NAME}.ini" else WEBRTC_PID="/var/run/spreed-webrtc.pid" WEBRTC_CONF_DEFAULT="/etc/spreed-webrtc/spreed-webrtc.ini" fi WEBRTC_CONF=${WEBRTC_CONF:-${WEBRTC_CONF_DEFAULT}} WEBRTC_EXEC=${WEBRTC_EXEC:-/usr/sbin/spreed-webrtc-server} depend() { need net use dns logger } checkconfig() { WEBRTC_CONF="${WEBRTC_CONF}" \ /usr/libexec/spreed-webrtc-checkconfig.sh || return 1 } start() { checkconfig || return 1 ebegin "Starting ${SVCNAME}" start-stop-daemon --start --exec ${WEBRTC_EXEC} --user spreed-webrtc \ --background --make-pidfile --pidfile "${WEBRTC_PID}" \ -- -c "${WEBRTC_CONF}" eend $? } stop() { ebegin "Stopping ${SVCNAME}" local retval=0 if [ -f ${WEBRTC_PID} ]; then start-stop-daemon --stop --pidfile ${WEBRTC_PID} || retval=1 pkill --full ${WEBRTC_CONF} else ewarn "Couldn't find ${WEBRTC_PID} trying to stop using the config filename ${WEBRTC_CONF}" pgrep --full ${WEBRTC_CONF} > ${WEBRTC_PID} start-stop-daemon --stop --pidfile ${WEBRTC_PID} || retval=1 pkill --full ${WEBRTC_CONF} fi eend ${retval} } # vim: ts=4