#!/bin/sh

# Make it login shell
if [ "$HAVE_LOGIN_SHELL" != "yes" ]; then
	export HAVE_LOGIN_SHELL=yes
	case $SHELL in
		*/csh|*/tcsh)
		# [t]cshrc is always sourced automatically.
		# Note that sourcing csh.login after .cshrc is non-standard.
		exec $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; exec $0 $*"
		;;
		*)
		exec $SHELL -l $0 $*
	esac
fi
unset HAVE_LOGIN_SHELL

# Call standard xinit actions
. /etc/X11/xinit/xinitdefs

case $1 in
failsafe)
	exec xterm -geometry 80x24-0-0
	;;
""|default)
	# take default action
	if [ -x "$HOME/.Xclients" ]; then
	    exec "$HOME/.Xclients"
	else
	    exec /etc/X11/xinit/Xclients
	fi
	;;
custom)
	if [ -x "$HOME/.xsession" ]; then
	    exec "$HOME/.xsession"
	else
	    exec xmessage -center -buttons OK:0 -default OK \
	    "Sorry, $HOME/.xsession not found."
	fi
	;;
*)
	exec /etc/X11/xinit/Xclients $1
esac
