NetBSD/etc/rc.d/sysdb

93 lines
1.5 KiB
Plaintext
Raw Normal View History

2000-03-10 14:53:23 +03:00
#!/bin/sh
#
# $NetBSD: sysdb,v 1.21 2009/06/18 22:00:04 christos Exp $
2000-03-10 14:53:23 +03:00
#
# PROVIDE: sysdb
# REQUIRE: mountcritremote
# BEFORE: DAEMON
2000-03-10 14:53:23 +03:00
$_rc_subr_loaded . /etc/rc.subr
2000-03-10 14:53:23 +03:00
name="sysdb"
rcvar=$name
2000-03-10 14:53:23 +03:00
start_cmd="sysdb_start"
stop_cmd=":"
extra_commands="devdb utmp services netgroup password"
devdb_cmd="build_devdb"
utmp_cmd="build_utmp"
services_cmd="build_services"
netgroup_cmd="build_netgroup"
password_cmd="build_password"
echo=:
2000-03-10 14:53:23 +03:00
sysdb_start()
{
echo -n "Building databases:"
echo=echo
comma=" "
$devdb_cmd
$utmp_cmd
$services_cmd
$netgroup_cmd
$password_cmd
echo " done"
}
check_file()
{
local src="$1"
local db="$2"
shift 2
if [ ! -e "$src" ]; then
return
fi
if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
$echo -n "$comma$(basename "$src")"
comma=", "
"$@"
fi
}
build_services()
{
check_file /etc/services /var/db/services.db services_mkdb -q
}
build_netgroup()
{
check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb
}
build_devdb()
{
check_file /dev /var/run/dev.db dev_mkdb
}
build_password()
{
local p=/etc/master.passwd
check_file $p /etc/spwd.db pwd_mkdb -w $p
}
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).
#
local i
for i in "" x; do
if [ ! -f /var/run/utmp$i ]; then
$echo -n "${comma}utmp$i"
comma=", "
install -c -m 664 -g utmp /dev/null /var/run/utmp$i
fi
done
2000-03-10 14:53:23 +03:00
}
load_rc_config $name
2000-03-10 14:53:23 +03:00
run_rc_command "$1"