#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          pagure-ev-server
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: 
# Description:       
#                    <...>
#                    <...>
### END INIT INFO

# Author: Sergio Durigan Junior <sergiodj@sergiodj.net>

DESC="pagure"
DAEMON="/usr/share/pagure-ev-server/bin/pagure-stream-server.py"
PIDFILE="/var/run/pagure/pagure-ev-server.pid"
U="git"

test -x "${DAEMON}" || exit 0

. /lib/lsb/init-functions

case "${1}" in
	start)
		start-stop-daemon --start --background -m --oknodo --pidfile $PIDFILE --chuid ${U}:${U} --exec $DAEMON
		;;

	stop)
		start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec ${DAEMON}
		rm -f $PIDFILE
		;;

	restart)
		${0} stop
		${0} start
		;;

	status)
		status_of_proc "${DAEMON}" "Pagure EV Server"
		;;

	*)
		echo "Usage: ${0} {start|stop|restart|status}"
		exit 1
		;;
esac

exit 0
