#!/bin/sh
#  Edit-Time-stamp: <1998-10-30 12:38:08 bakken>
if [ "${1:-}" = "-x" ] ; then set -xv; shift; fi
set -u  # force better programming and ability to use check for not set

# the first parameter is the pnfs node.  if not entered, use the default
if [ $# -ge 1 ] ; 
then
    pnfsNode=$1;
    shift;
else
    pnfsNode=pcfarm9
fi

if [ `uname -n | grep -c $pnfsNode` -ne 0 ] ; then
  echo "You can not run this on the pnfs server node $pnfsNode, only remote client nodes"
  exit 1
fi

options="hard,intr,rw,noac"

mp="enstore"
if [ `uname -n | grep -c airedale` -ne 0 ] ; then 
  mp="enstore d0sam d0ola cdftst"
fi

if [ -z "${1-}" -o  "${1:-x}" = "mount" ] ; then
  for i in $mp; do
    cmd="mount -o $options $pnfsNode:/$i  /pnfs/$i"
    echo $cmd
    eval $cmd
  done

elif [ "$1" = "umount" ] ; then
  for i in $mp; do
    cmd="umount /pnfs/$i"
    echo $cmd
    eval $cmd
  done

elif [ "$1" = "cycle" ] ; then
  $0 umount
  $0 mount

elif [ "$1" = "mkdir" ] ; then
  now=`pwd`
  cd /
  for i in $mp; do
    cmd="mkdir -p /pnfs/$i"
    echo $cmd
    eval $cmd
  done
  cd $now

else
  echo "do not understand $1.  Usage: $0 <mount|umount|mkdir>"
  exit 1
fi
