#!/bin/ksh
# Copyright (c) 06/12/01 Sun Microsystems, Inc. All Rights Reserved
# @(#)utrmdpy.sh	1.7 01/06/12
#
# 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
DPYFILE=$DISPDIR/$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
