#!/bin/ksh -p
#
# ident "@(#)xdm-remove-dpy.sh	1.3 04/01/20"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
#
# utility script to remove X server configuration from
# system configuration files for a token 
#
# The database of available display numbers is taken as 
# Xservers. If a display is mentioned as
#
#	sysname:num OR :num
#
# at the beginning of a line or the beginning of a comment, it is considered
# unavailable for use.
#
# E.g. a line '# :3 RESERVED' will prevent display 3 from being assigned
#

verbose=0
umask 0022
unset LD_LIBRARY_PATH

BASE=/etc/opt/SUNWut/basedir
SUNWUT=$BASE
SUNWUTLIB=$SUNWUT/lib

dir=$1		# configuration directory location
token=$2	# token name
rmdisplay=$3	# rm display command line

xserv=$dir/Xservers     # DMNAME's Xservers file
xconf=$dir/Xconfig      # DMNAME's Xconfig file
xconfiglock=$dir/config.lock    # X-Windows config lock file

#
# Remove the display file on success -> this must be atomic
# because the display number may be reassigned immediately
#


$SUNWUTLIB/utdtutil -l $xconfiglock -D "_TOKEN=$token\>" -r "$rmdisplay" \
		$xserv $xconf >/dev/null

