#!/bin/sh
# Start script for FreeBSD, contributed by user Fabian Abplanalp
# Put this script in /usr/local/etc/rc.d then adjust GALENE_BIN and
# GALENE_CFG values in /etc/defaults/galene

GALENE_BIN="/usr/local/bin/galene"
GALENE_PID="/var/run/galene.pid"

# Read configuration variable file if it is present
[ -r /etc/defaults/galene ] && . /etc/defaults/galene

case "$1" in
"start")
	echo "Starting galene..."
	${GALENE_BIN} &
	echo $! >${GALENE_PID}
	echo "done"
	;;

"stop")
	echo "Stopping galene..."
	if [ -f ${GALENE_PID} ]; then
		kill $(cat ${GALENE_PID})
		rm ${GALENE_PID}
		echo "done"
	else
		echo "not running?"
	fi
	;;

"restart")
	echo "Restarting galene..."
	$0 stop
	sleep 2
	$0 start
	;;

*)
	echo "$0 [start|stop|restart]"
	;;

esac
