#!/bin/sh
# Startup script for prelude-lml
#
# chkconfig: 2345 98 01
# description: Run prelude-lml

# Source function library.
. /etc/rc.d/init.d/functions

# Get service config
if [ -f /etc/sysconfig/prelude-lml ]; then
        . /etc/sysconfig/prelude-lml
else
	nls "Error: %s not found" /etc/sysconfig/prelude-lml
	nls " Prelude LML can't be run."
        exit 1
fi

start() {
	if [ ! -f /var/lock/subsys/prelude-lml ]; then
		msg_starting "Prelude LML"
		daemon prelude-lml -d
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/prelude-lml
	else
		msg_already_running "Prelude LML"
	fi
}

stop() {
	if [ -f /var/lock/subsys/prelude-lml ]; then
		msg_stopping "Prelude LML"
		killproc prelude-lml
		rm -f /var/lock/subsys/prelude-lml
	fi
}

condrestart() {
	if [ -f /var/lock/subsys/prelude-lml ]; then
		stop
		start
	else
		msg_not_running "Prelude LML"
		RETVAL=$1
	fi
}

RETVAL=0
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  reload|force-reload)
	if [ -f /var/lock/subsys/prelude-lml ]; then
		msg_reloading "Prelude LML"
		killproc prelude-lml -HUP
		RETVAL=$?
	else
		msg_not_running prelude-lml >&2
		exit 7
	fi
	;;
  status)
	status prelude-lml
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
	exit 1
esac

exit 0
