#!/bin/bash
#
# chkconfig: 345 84 19
# description: FileMaker Server 5.5 
#
#
# Source function library.
. /etc/rc.d/init.d/functions

# Path to the fmserverd binary
fmserverd=/usr/bin/fmserverd

# Arguments passed to fmserverd
start_args="start -c /etc/fmserver.conf"
stop_args="stop"

start() 
{
	echo -n "Starting fmserverd: "
	${fmserverd} ${start_args} 
	RETVAL=$?
	if [ $RETVAL = 0 ]; then
		echo_success
	else
		echo_failure
	fi
	echo
	return $RETVAL
}

stop()
{
	echo -n "Stopping fmserverd: "
	${fmserverd} ${stop_args} > /dev/null 2>&1 && echo_success || echo_failure
	RETVAL=$?
	echo
	return $RETVAL
}

case "$1" in 
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status ${fmserverd}
		;;
	restart)
		stop
		start
		;;
	reload)
		echo -n "Reloading Configuration File: "
		${fmserverd} reload > /dev/null 2>&1 && echo_success || echo_failure
		RETVAL=$?
		echo 
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|status}"
		exit 1
esac

exit $RETVAL
