#ident	"@(#)rfs.admin:resrcmgmt/mountmgmt/lsavail	1.3"
#menu# list remote resources that are available to mount

#help# 
#help#	The subcommand "lsavail" shows you a list of all the resources
#help#	that are currently available from other machines in your domain.
#help# 	Resources are available if they have been advertised by the 
#help#	other machines.  To use a resource, you must mount it on a 
#help#	directory in your file system.	
#help#

#set trap
trap '/bin/rm -f /usr/tmp/lsavail$$ /usr/tmp/lsav$$; trap 0; exit' 0 1 2 3 15

# print heading
echo "\n\n\t\tREMOTE RESOURCES CURRENTLY AVAILABLE"
HEADING="
Remote resources are available if they have been advertised by other
machines.  Resources can only be available when RFS is running on your
machine.

The fields on this list are in the following order:
Resource identifier, Access permissions, Advertising machine, Description.
Please wait for the list...
-------------------------------------------------------------------------"

echo "$HEADING\n"
# If RFS is running, then determine which resource are advertised, which belongs
# to the system executing the program, and print the resources advertised that does
# not belong to the current executing system.
# If RFS is not running then print appropriate message.
if /usr/lbin/rfsrunning
then
	/usr/bin/nsquery -h `/bin/uname -n` >/usr/tmp/lsavail$$
	/usr/bin/nsquery -h | /usr/bin/fgrep -v -f/usr/tmp/lsavail$$ > /usr/tmp/lsav$$

	if [ -s /usr/tmp/lsav$$ ] 
	then
		 /bin/sort /usr/tmp/lsav$$ | /usr/bin/pg  -e -p"Enter <RETURN> to continue:" 
	else
		echo "There are no remote resources currently available.\n"
	fi
else
	echo "\nRFS is NOT running on your machine."
	echo "There are no remote resources available.\n"
fi
