#!/bin/sh
#@(#)HP X Station Admin Scripts
#
# cknfs		Check if nfsd is running
#

$PSCMD | egrep -v pcnfs | egrep -v egrep | egrep nfsd > /dev/null
if [ $? -eq 0 ]
then
  echo
  echo "nfsd is running"
else
  echo
  echo "nfsd is not running"
  echo "Pleases consult your System Adminstration Documentation"
  echo "to determine how to enable this host as an NFS server."
  exit 90
fi


$PSCMD | egrep -v egrep | awk '{print $NF}' |  egrep mountd > /dev/null
if [ $? -eq 0 ]
then
  echo
  echo "mountd is running"
else
  echo
  echo "mountd is not running"
  echo "Pleases consult your System Adminstration Documentation"
  echo "to determine how to enable this host as an NFS server."
  exit 90
fi


  # This is for HP-UX
  #
if [ "$INSTALLDIR" = "unknown" ]
then
  INSTALLDIR=""
fi

FS=`wherelives $XTHOME 2> /dev/null`
echo "$FS" | egrep '^/' > /dev/null
if [ $? -ne 0 ]
then
  echo
  echo could not determine filesystem of $XTHOME
  echo giving up ..
  echo
  exit 90
fi

getxtname "check (netgroup if applicable)"

if [ $? -ne 0 ]
then
  exit 90
fi


XTNAME=`cat $TMP/XTNAME | awk -F'.' '{print $1}'`
rm  $TMP/XTNAME

xtutil_can-mount $XTNAME $XTHOME
if [ $? -eq 0 ]
then
  echo
  echo X Station seems to be allowed to mount
  echo $XTHOME from this host
  exit 0
fi


showmount -e | awk '$1 == "'$FS'"' \
	| egrep "[,         ]$XTNAME(([,])|([ ])|($))" > /dev/null
if [ $? -ne 0 ]
then
  showmount -e | awk '$1 == "'$FS'"' \
	| egrep "everyone" > /dev/null
  if [ $? -ne 0 ]
  then
    echo
    echo X Station does not seem to be allowed to mount
    echo $XTHOME from this host
    echo Please add terminal to /etc/exports and have /etc/exports 
    echo 're-read by executing an "exportfs -a"'
    exit 90
  fi
fi
  
echo
echo X Station seems to be allowed to mount
echo $XTHOME from this host

exit 0
