#!/bin/sh
# $Id: pnfs,v 1.1 2006-11-07 14:10:15 tigran Exp $
#
# chkconfig: - 91 9
# description: pnfs startup script
#
#pnfs_location=/opt/pnfs.3.1.10

if [ -r /usr/etc/pnfsSetup ]
then
 . /usr/etc/pnfsSetup
else
	echo "pnfs is not configured. Exiting"
	exit 1;
fi

#if [ -r /etc/rc.d/init.d/functions ]
#then
# . /etc/rc.d/init.d/functions
#fi

RETVAL=0

case "$1" in
   start)
      echo "Starting pnfs services (PostgreSQL version): "
      [ -d $dCache_location ] || exit 1
      ${pnfs}/tools/pnfs.server start
      sleep 2
      mount -o udp,intr,rw,noac,hard,nfsvers=2 localhost:/fs /pnfs/fs
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dcache
	;;

  stop)
      echo "Shutting down pnfs services (PostgreSQL version): "
      umount /pnfs/fs
      ${pnfs}/tools/pnfs.server stop
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/gmond
	;;

  restart|reload)
   	$0 stop
   	$0 start
   	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $RETVAL
