#!/bin/sh
pwfile=/var/yp/master/passwd
ypmaster=`ypwhich -m passwd`
user=$1

if [ $# = 0 ]; then
	echo "Usage: $0 user"
	exit 1;
fi

# Find the home directory from the passwd file.
if [ "$ypmaster" ]; then
	pwent=`ypmatch $user passwd`
else
	pwent=`grep $user $pwfile`
fi

if [ "$pwent" = "" ]; then
	echo "No passwd entry for $user"
	exit 2;
fi

homedir=`echo $pwent | awk -F: '{print $6}'`

if [ "$homedir" = "" ]; then
	echo "No home directory for $user in passwd entry"
	exit 3;
fi
if  [ ! -d  $homedir ]; then
	echo "Home directory unavailable"
	exit 4;
fi
exit 0
