#!/bin/bash
#
# ms        Startup script for the metadata service
#
# chkconfig: 235 90 10
# description: The metadata service is a powerful combination of an \
#             indexer and a search engine for all kinds of documents.
# processname: metadata-service
# config: /etc/metadata-service.conf

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

# Path to the msctl script, server binary, and short-form for messages.
msctl=/usr/bin/msctl
metadata_service=${METADATA_SERVICE-/usr/bin/metadata-service}
prog=metadata-service
lockfile=${LOCKFILE-/var/lock/subsys/metadata-service}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon $msctl start $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}
stop() {
	echo -n $"Stopping $prog: "
	$msctl stop > /dev/null 2>&1 < /dev/null
   ret=$?
   if [ $ret -eq 0 ]
   then
       echo_success
   else
       echo_failure
   fi
   echo

	RETVAL=$ret
	[ $RETVAL = 0 ] && rm -f ${lockfile}
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status $metadata_service
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|status|help}"
	exit 1
esac

exit $RETVAL
