#!/bin/bash
#
# fdfs_trackerd Starts fdfs_trackerd
#
#
# chkconfig: 2345 99 01
# description: FastDFS tracker server
### BEGIN INIT INFO
# Provides: $fdfs_trackerd
### END INIT INFO

# Source function library.
if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
fi

PRG=/usr/bin/fdfs_trackerd
CONF=/etc/fdfs/tracker.conf

if [ ! -f $PRG ]; then
  echo "file $PRG does not exist!"
  exit 2
fi

if [ ! -f $CONF ]; then
  echo "file $CONF does not exist!"
  exit 2
fi

CMD="$PRG $CONF"
RETVAL=0

start() {
 	echo -n $"Starting FastDFS tracker server: "
	$CMD &
	RETVAL=$?
	echo
	return $RETVAL
}
stop() {
    $CMD stop
	RETVAL=$?
	return $RETVAL
}
rhstatus() {
	status fdfs_trackerd
}
restart() {
        $CMD restart &
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
  	rhstatus
	;;
  restart|reload)
  	restart
	;;
  condrestart)
  	restart
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	exit 1
esac

exit $?

