#! /bin/ksh
#############################################################################
#
#   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 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.
#
#   $Revision: 1.15 $
#
#   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 [ "$DTXSERVERLOCATION" = "local" ]
then
  if [[ ! -z "$ITE" && "$ITE" != "??" && -a "/dev/$ITE" ]]
  then
        chown $USER /dev/$ITE
        chgrp $USER_GID  /dev/$ITE
        if [ "$ITE" = "console" ]
        then
           chown $USER /dev/$ITE/0 >/dev/null 2>&1
           chgrp $USER_GID /dev/$ITE/0 >/dev/null 2>&1
        fi
  fi
fi

#
# If the dtdbcache_$DISPLAY file exists and it is NOT owned by the
# the current user, than it must be removed.
#

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