:
# Prowl - Skunkware 5.0 shell script front-end to Mosaic to set the
#         home page. This is necessary because on SCO OpenServer 5
#         a /usr/lib/X11/app-defualts/Mosaic will already be installed
#         and a default home page already configured.

# if no argument specified, query the user on the type of display

ans=
X=
QUERY=1
LCFG=/usr/skunk/lib/lynx/lynx.cfg
HOMEPAGE=/usr/skunk/lib/X11/Mosaic/index.html

useage() {
	echo "Useage: prowl [-c | -x | -s]"
	echo "\tWhere -c indicates use character mode browser,"
	echo "\t      -x indicates use X11 graphical browser,"
	echo "\t      -s indicates choose browser based on DISPLAY."
	exit 1
}

getyn() {
	ans=
	while [ "$ans" = "" ]
	do
		read ans
		[ "$ans" = "Y" ] || [ "$ans" = "y" ] && {
			ans=Y
			break
		}
		[ "$ans" = "n" ] || [ "$ans" = "N" ] && {
			ans=N
			break
		}
		ans=
		echo "\nPlease answer with a Y or N \c"
	done
}

echo $PATH | grep /usr/skunk/bin/X11 > /dev/null || {
	PATH=$PATH:/usr/skunk/bin:/usr/skunk/bin/X11
	export PATH
}

while case "$1" in
	"")	break 
		;;
	-c)	[ "$X" = 1 ] && useage
		X=2
		;;
	-x)	[ "$X" = 2 ] && useage
		X=1
		;;
	-s) QUERY=
		[ "$X" ] || X=0
		;;
	*)  useage
		;;
	esac
do
	shift
done

[ "$X" = "" ] && [ "$QUERY" ] && {
	echo "Are you using an X11 display (type Y if you don't know) ? <Y/N>\c"
	getyn
	X=0
	[ "$ans" = "Y" ] && X=1
}

if [ "$DISPLAY" ]
then
	[ $X = 0 ] && [ "$QUERY" ] && {
		echo "DISPLAY environment variable is set."
		echo "In order to browse with Lynx, unset DISPLAY in your environment."
		echo "Using Mosaic X11 browser."
		echo "Ok ? <Y/N>\c"
		getyn
		[ "$ans" = "N" ] && {
			echo "Exiting"
			exit 1
		}
	}
    /usr/skunk/bin/X11/Mosaic -home $HOMEPAGE
else
	[ $X = 1 ] && [ "$QUERY" ] && {
		echo "DISPLAY environment variable is not set."
		echo "In order to browse with Mosaic, set DISPLAY in your environment."
		echo "Using Lynx character browser."
		echo "Ok ? <Y/N>\c"
		getyn
		[ "$ans" = "N" ] && {
			echo "Exiting"
			exit 1
		}
	}
    /usr/skunk/bin/lynx -cfg=$LCFG file:$HOMEPAGE
fi
