#!/sbin/sh
#
# Copyright (c) 1998-2000 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)devfsadm	1.7	00/10/10 SMI"

case "$1" in
'start')
	/usr/lib/sysevent/syseventd >/dev/msglog 2>&1
	/usr/lib/sysevent/syseventconfd >/dev/msglog 2>&1

	if [ -n "$_INIT_RECONFIG" ]; then
		echo 'Configuring /dev and /devices'
		/usr/sbin/devfsadm >/dev/msglog 2>&1
	        if [ -x /usr/ucb/ucblinks -a -f /usr/ucblib/ucblinks.awk ]; then
	                echo 'Configuring the /dev directory (compatibility devices)'
	                /usr/ucb/ucblinks >/dev/null 2>&1
	        fi

		#
		# Flush any existing socket mappings since the major numbers of
		# the device files may have changed.
		#
		/usr/bin/awk '/^[^#]/ { print $1, $2, $3 }' /etc/sock2path \
			>/tmp/sock2path.$$
		/sbin/soconfig -f /tmp/sock2path.$$ >/dev/null 2>&1
		/usr/bin/rm -f /tmp/sock2path.$$
		/sbin/soconfig -f /etc/sock2path >/dev/null 2>&1
	fi

	# Establish the default framebuffer name.

	fbdev=`/usr/sbin/prtconf -F 2>/dev/null`

	if [ $? -eq 0 ]; then
		set -- /devices$fbdev*
		if [ -c $1 ]; then
			rm -f /dev/fb
			ln -s $1 /dev/fb
		fi
	fi
	;;

#
# devfsadmd and rcm_daemon are started on-demand by syseventd
#
'stop')
	/usr/bin/pkill -x -u 0 -P 1 rcm_daemon
	/usr/bin/pkill -x -u 0 -P 1 devfsadm
	/usr/bin/pkill -x -u 0 -P 1 syseventd
	/usr/bin/pkill -x -u 0 -P 1 syseventconfd
	;;	

*)
	echo "Usage: $0 { start | stop }"
	;;

esac
exit 0
