#!/bin/sh

# openflax.sh v2004.0104

# Script to start OpenFlax at system boot time.
# This script is written for FreeBSD 4.9, and it
# is intended to be put into /usr/local/etc/rc.d
# where it will be executed automatically at boot.
# It is however fairly generic and should be easy
# to adapt to other UNIX-like operating systems.

OPENFLAX_ERL=/usr/local/bin/erl
OPENFLAX_BEAM=beam
OPENFLAX_USER=www
OPENFLAX_CONF=/home/$OPENFLAX_USER/openflax.conf
OPENFLAX_CMD="$OPENFLAX_ERL -detached -run openflax.app start $OPENFLAX_CONF"

case "$1" in
	start)
		su $OPENFLAX_USER -c "$OPENFLAX_CMD"
		echo -n " openflax"
	;;
	stop)
		killall -u $OPENFLAX_USER $OPENFLAX_BEAM
	;;
	restart)
		$0 stop
		$0 start
	;;
	*)
		echo "usage: `basename $0` (start | stop | restart)" >&2
		exit 64
	;;
esac


