NetBSD/etc/rc.d/sysdb
atatat a67080c774 Reorganize the sysdb script so that lkm{1,2,3} can request that the
dev database be rebuilt after loading modules.  Loading modules might
create new nodes in /dev, but the dev database is being initialized
too soon for lkm2 and lkm3.  This means that, eg, /dev/xf86 (typically
marked AFTERMOUNT and loaded by lkm2) will show up properly.  Reviewed
by lukem.
2002-10-08 16:21:52 +00:00

60 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: sysdb,v 1.11 2002/10/08 16:21:52 atatat Exp $
#
# PROVIDE: sysdb
# REQUIRE: mountcritremote
# BEFORE: DAEMON
. /etc/rc.subr
name="sysdb"
start_cmd="sysdb_start"
stop_cmd=":"
extra_commands="kvmdb devdb utmp"
kvmdb_cmd="build_kvmdb"
devdb_cmd="build_devdb"
utmp_cmd="build_utmp"
sysdb_start()
{
echo "Building databases..."
build_kvmdb
build_devdb
build_utmp
}
build_kvmdb()
{
# 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.
#
booted_kernel=`sysctl -n machdep.booted_kernel 2>/dev/null`
kvm_mkdb "${booted_kernel:-/netbsd}"
}
build_devdb()
{
if [ /var/run/dev.db -nt /dev ]; then
# it's fine
else
dev_mkdb
fi
}
build_utmp()
{
# Re-create /var/run/utmp and /var/run/utmpx, which are
# 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
install -c -m 664 -g utmp /dev/null /var/run/utmpx
}
load_rc_config $name
run_rc_command "$1"