#!/bin/sh
# Assign ownership of the console to the invoking user
#
# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output.  This way a random user can invoke xterm -C without
# causing serious grief.
#
chown $USER /dev/console
#
# Xstartup
#
# This program is run as root after the user is verified
#
########################################
# Check to make sure logins are
# currently enabled
#
if [ -f /etc/nologin -a $USER != root ]; then
  /usr/etc/intr -t 20 /usr/bin/X11/xmessage -file /etc/nologin -default button
  exit 1
fi

if [ $USER = halt ]; then
	if [ "`users`" = "" ]; then
		xterm -e /etc/reboot &
        	sleep 10
		exit 1
	else
		xmessage Can\'t reboot when users logged in! &
		sleep 5
		exit 1
	fi
fi


#########################################
# Check to make sure shell is valid
# and perform wtmp accounting
#
if /usr/lib/X11/xdm/xdm-login-accounting -login $USER $DISPLAY
 then
	:
 else
	/usr/etc/intr -t 10 /usr/bin/X11/xmessage 'Login shell not in /etc/shells'
	exit 2;
fi

exit 0
