#!/bin/sh
#
# $NetBSD: sysdb,v 1.2.4.2 2000/10/02 01:09:27 lukem Exp $
#

# PROVIDE: sysdb
# REQUIRE: mountcritremote

. /etc/rc.subr

name="sysdb"
start_cmd="sysdb_start"
stop_cmd=":"

sysdb_start()
{
	#	Build ps databases. If this kernel supports
	#	machdep.booted_kernel, use that to build the KVM db so dmesg
	#	will run work when we boot /netbsd.new, etc.
	#
	echo "Building databases..."
	sysctl machdep 2>/dev/null | grep -q booted_kernel
	if [ $? -eq 0 ] ; then
		kvm_mkdb `sysctl -n machdep.booted_kernel` || kvm_mkdb /netbsd
	else
		kvm_mkdb /netbsd
	fi
	dev_mkdb

	#	Re-create /var/run/utmp, which is deleted by mountcritlocal
	#	but can't be recreated by it because install and chown may
	#	not be available then (possibly no /usr).
	#
	install -c -m 664 -g utmp /dev/null /var/run/utmp
}

load_rc_config $name
run_rc_command "$1"
