#!/bin/sh
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)svc-kdmconfig	1.4	05/10/21 SMI"

. /lib/svc/share/smf_include.sh

if [ ! -x /usr/openwin/bin/kdmconfig ]; then
	exit $SMF_EXIT_ERR_CONFIG
fi

TERM=sun-color export TERM

echo BOOT > /tmp/.kdmboot
/usr/openwin/bin/kdmconfig -t < /dev/console > /dev/console 2>&1
/usr/bin/rm /tmp/.kdmboot

if [ -x /usr/X11/bin/Xorg ] &&
   [ -x /usr/openwin/lib/prtvideodevs ] &&
   [ -d /etc/X11 ]; then
	/usr/openwin/lib/prtvideodevs > /etc/X11/.video.devs.new 2>/dev/null
	diff /etc/X11/.video.devs /etc/X11/.video.devs.new > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		/usr/bin/mv /etc/X11/.video.devs.new /etc/X11/.video.devs
		/usr/X11/bin/Xorg -configure > /dev/null 2>&1
		if [ -f /xorg.conf.new ]; then
			/usr/bin/mv /xorg.conf.new /etc/X11/.xorg.conf
		fi
	fi
	/usr/bin/rm -f /etc/X11/.video.devs.new
fi
		
exit $SMF_EXIT_OK
