#! /bin/ksh
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident  "@(#)Xstartup.src 1.21     04/06/11 SMI; TSOL 2.x"
#
#############################################################################
#
#   Xstartup
#
#   Common Desktop Environment (CDE)
#
#   Configuration file for the Login Manager
#
#   (c) Copyright 1993, 1994 Hewlett-Packard Company
#   (c) Copyright 1993, 1994 International Business Machines Corp.
#   (c) Copyright 1993, 1994, 2001 by Sun Microsystems, Inc.
#   (c) Copyright 1993, 1994 Novell, Inc.
#
#       ************** DO NOT EDIT THIS FILE **************
#
#   /usr/dt/config/Xstartup is a factory-default file and will
#   be unconditionally overwritten upon subsequent installation.
#   Before making changes to the file, copy it to the configuration 
#   directory, /etc/dt/config. You must also update the startup
#   resource in /etc/dt/config/Xconfig.
#
#   $XConsortium: Xstartup.src /main/cde1_maint/3 1995/10/03 17:50:05 gtsang $
#
#   This file is typically a shell script. It is run as "root" and should be
#   very careful about security. This is the place to put commands that display
#   the message of the day or do other system-level functions on behalf of the
#   user. The following are the environment variables set for use in the script:
#
#	DISPLAY, HOME, PATH, USER, SHELL, TZ (timeZone)
#
#   System Administrators are encouraged to use this file as a base to run 
#   system-wide initialization commands with good security.
#
#
#
#
#############################################################################


#
# This script is run as root after the user is verified...
#

if [ -f /tmp/dtdbcache_$DISPLAY ]
then
  DSTDBFILE=`/bin/echo /tmp/dtdbcache_$DISPLAY | /bin/sed 's/\..*//'`
  DSTDBFILEOWNER=`/bin/ls -l $DSTDBFILE | /bin/awk '{print $3}'`
  if [ $USER != $DSTDBFILEOWNER ]
  then
	/bin/rm -rf $DSTDBFILE
  fi
fi


if [ "$DTXSERVERLOCATION" = "local" ]
then
  if [[ ! -z "$ITE" && "$ITE" != "dtlocal" && -a "/dev/$ITE" ]]
  then
        /bin/chown $USER /dev/$ITE
        /bin/chgrp  tty  /dev/$ITE
  fi
fi


#
# Trusted Solaris changes for SunRay
# Source 0100.SUNWut, pass envs through file
#
SUNWut_STARTUP=/usr/dt/config/Xsession.d/0100.SUNWut
if [ -f $SUNWut_STARTUP ] ; then
	# Disable screen lock via utxlock
	SUN_SUNRAY_UTXLOCK_PREF=
	# Defer session reaper to sessionetc
	UT_REAPER_MAY_DEFER=1
	# Run the SunRay startup file
	. $SUNWut_STARTUP
	# store SunRay specific env variables
	UTENVROOT=${DISPLAY#*:}
	UTENVROOT=${UTENVROOT%.*}
	if [ "X$UTENVROOT" != "X" ] ; then
		UTENVDIR=/tmp/SUNWut/tsol
		if [ ! -d $UTENVDIR ] ; then
			/bin/mkdir $UTENVDIR
		fi

		UTENVFILE=$UTENVDIR/${UTENVROOT}_utenv
		echo "export UTDEVROOT=$UTDEVROOT" > $UTENVFILE
		echo "export AUDIODEV=$AUDIODEV" >> $UTENVFILE
		echo "export UTAUDIODEV=$AUDIODEV" >> $UTENVFILE

		if [ "X$DTDEVROOT" != "X" ] ; then
			echo "export DTDEVROOT=$DTDEVROOT" >> $UTENVFILE
		fi
	fi
fi

