#!/bin/ksh -p
#
# ident "@(#)utrmdpy.sh	1.9 05/02/15 SMI"
#
# Copyright 1999-2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Remove the insert token links to the display file, if there, and
# the display file itself.

INFODIR=/var/opt/SUNWut
DISPDIR=$INFODIR/displays
RESDIR=$INFODIR/dispinfo
INSERTDIR=$INFODIR/itokens
CTOKENDIR=$INFODIR/ctokens
IDLEDIR=$INFODIR/idle
DPYFILE=$DISPDIR/$1
IDLEFILES=$IDLEDIR/$1.*
SESSIONPROC=/tmp/SUNWut/session_proc/$1
RESFILE=$RESDIR/$1
LASTLANGFILE=/var/dt/sdtlogin/lastlang_$1

sed -n '/INSERT_TOKEN=/s/INSERT_TOKEN=//p' $DPYFILE | \
	while read rtid 
	do
		/bin/rm -f $INSERTDIR/$rtid
	done
sed -n '/^TOKEN=/s/TOKEN=//p' $DPYFILE | \
	while read tid 
	do
		/bin/rm -f $CTOKENDIR/$tid
	done
/bin/rm -f $DPYFILE $RESFILE $LASTLANGFILE $SESSIONPROC $IDLEFILES
