#! /bin/ksh
#############################################################################
#
#   Xreset
#
#   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/Xreset 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 reset
#   resource in /etc/dt/config/Xconfig.
#
#   $Revision: 1.13 $
#
#
#   This file is symmetrical with Xstartup. This script is run after the user
#   session is terminated. Run as root, it should probably contain commands 
#   that undo the effects of commands in Xstartup, such as unmounting directories
#   from file servers. The collection of environment variables that were passed
#   to Xstartup are also passed to Xreset.
#
#############################################################################

#
# This script is run as root after the session terminates but
# before the display is closed...
#

if [ "$DTXSERVERLOCATION" = "local" ]
then
  if [[ ! -z "$ITE" && "$ITE" != "??" && -a "/dev/$ITE" ]]
  then
        chown root /dev/$ITE
        chgrp $ROOT_GID  /dev/$ITE
        if [ "$ITE" = "console" ]
        then
            chown root /dev/$ITE/0 >/dev/null 2>&1
            chgrp $ROOT_GID  /dev/$ITE/0 > /dev/null 2>&1
        fi
  fi
fi

#
# Normally the dtdbcache_$DISPLAY file has been previously removed.
# Circumstances however may not be normal.
#

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