#!/sbin/sh
#
# Copyright 1998-2000,2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)devfsadm	1.8	02/10/21 SMI"

case "$1" in
'start')
	/usr/lib/sysevent/syseventd >/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, rcm_daemon and syseventconfd are started on-demand
# by syseventd. syseventd should be stopped before others.
#
'stop')
	/usr/bin/pkill -x -u 0 -P 1 syseventd
	/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 syseventconfd
	;;	

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

esac
exit 0
