#!/bin/sh
if [ x$DISPLAY = x ]; then
	cat /mit/sipb/share/Mosaic/no-display.txt
	exit 1
fi

machtype=`/bin/athena/machtype`
/bin/athena/attach -q -n -h -a -r graphics mime gnu outland sipb library
/bin/athena/attach -q -h -a -r pgp
PATH=${PATH}:/mit/graphics/bin:/mit/mime/bin:/mit/gnu/bin:/mit/outland/bin:/mit/pgp/bin:/mit/library/bin

case "$machtype" in
sgi)
	;;
linux|inbsd)
	if [ x$XKEYSYMDB = x ]; then
		XKEYSYMDB=/usr/X11/lib/X11/XKeysymDB
		export XKEYSYMDB
	else
		if [ ! -r ${XKEYSYMDB} ]; then
			zwrite ${USER} -n -d -m 'Mosaic is unable to find its Motif Keysyms.'
		fi
	fi
	if [ x$XNLSPATH = x ]; then
		XNLSPATH=/usr/X11/lib/X11/nls
		export XNLSPATH
	fi
	;;
*)
	if [ ! -r "/mit/x11/${machtype}lib/X11/XKeysymDB" ]; then
		if [ x$XKEYSYMDB = x ]; then
			XKEYSYMDB=/afs/athena/astaff/project/x11r5/${machtype}lib/X11/XKeysymDB
			export XKEYSYMDB
		else
			attach -q -n -h -a -r x11r5 motif1.2	
			if [ ! -r ${XKEYSYMDB} ]; then
				zwrite ${USER} -n -d -m 'Mosaic is unable to find its Motif Keysyms: "detach x11"'
			fi
		fi
	fi
	if [ x$XNLSPATH = x ]; then
		XNLSPATH=/afs/athena/astaff/project/x11r5/${machtype}lib/X11/nls
		export XNLSPATH
	fi
	;;
esac

SEARCHPATH=/mit/sipb/share/X11/%T/%N
XFILESEARCHPATH=${XFILESEARCHPATH-}${XFILESEARCHPATH+:}${SEARCHPATH}
export PATH XFILESEARCHPATH

ATHENA_SYS=${ATHENA_SYS-"@sys"}
exec /mit/sipb/arch/${ATHENA_SYS}/bin/Mosaic.real "$@"
