#! /bin/ksh
#
# Getnfsdownlist - create a list of all down NFS servers that are
#		   mounted on the local system.
#
# Version: 1994/11/17.
#
# Usage: Getnfsdownlist [excludehost1 [excludehost2] ... ]
#
#
# Set the list of hosts to be ignored, even if they are down.
#
hostlist="$@"
#
# Load the system-dependent parameters.
#
if [ -f /usr/local/bin/Getsystemoptions ]; then
   . /usr/local/bin/Getsystemoptions
else
   echo "*** $0 can't find /usr/local/bin/Getsystemoptions ***"
   exit 1
fi
#
# Get the list of down hosts.
#
# Case 1: /tmp/.NFSdown exists: just get a list of all the links.
#
nfsdowndir=/tmp/.NFSdown
if [ -d $nfsdowndir ]; then
   cd $nfsdowndir
   for h in `ls`
   do
      for t in $hostlist
      do
         if [ "$h" = "$t" ]; then
            continue 2
         fi
      done
      echo "$h"
   done
#
# Case 2: /tmp/.NFSdown does not exist: do it the hard way.
#         Check all the down hosts to see if they are mounted on this node.
#
else
   if [ -f /etc/fstab ]; then
      fstab=/etc/fstab
   elif [ -f /etc/checklist ]; then
      fstab=/etc/checklist
   fi
   ruptimetmp=/tmp/ruptimetmp.$$
   ruptime -a >$ruptimetmp
#
   for h in `grep ' *down ' $ruptimetmp | awk '{print $1}'`
   do
      grep -s "^$h:/" $fstab >/dev/null
      if [ "$?" = "0" ]; then
         for t in $hostlist
         do
            if [ "$h" = "$t" ]; then
               continue 2
            fi
         done
         echo "$h"
      fi
   done
#
   cd /
   /bin/rm -f $ruptimetmp
#
fi
#
exit 0
#
# End of Getnfsdownlist.
#
