#!/bin/sh

# display local hostname, if it's a filesystem node
#
# if a gfarm file is specified as an argument, display local hostname,
# only if the host has its replica.

if	case $# in
	0)	host=`gfsched -n 1 -S -w 2>&1`;;
	1)	host=`gfsched -n 1 -S -f "$1" 2>/dev/null`;;
	*)	echo >&2 "Usage: get_local_gfhost [<gfarm_file>]"
		exit 2;;
	esac
then
	echo $host
	exit 0
else
	exit 1
fi
