2000-03-10 14:53:23 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2009-06-19 02:00:04 +04:00
|
|
|
# $NetBSD: sysdb,v 1.21 2009/06/18 22:00:04 christos Exp $
|
2000-03-10 14:53:23 +03:00
|
|
|
#
|
|
|
|
|
2000-09-19 17:04:38 +04:00
|
|
|
# PROVIDE: sysdb
|
2000-07-26 04:11:48 +04:00
|
|
|
# REQUIRE: mountcritremote
|
2002-03-22 07:33:57 +03:00
|
|
|
# BEFORE: DAEMON
|
2000-03-10 14:53:23 +03:00
|
|
|
|
2004-08-13 22:08:03 +04:00
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
2000-03-10 14:53:23 +03:00
|
|
|
|
|
|
|
name="sysdb"
|
2007-08-27 03:55:50 +04:00
|
|
|
rcvar=$name
|
2000-03-10 14:53:23 +03:00
|
|
|
start_cmd="sysdb_start"
|
|
|
|
stop_cmd=":"
|
2007-05-09 00:33:59 +04:00
|
|
|
extra_commands="devdb utmp services netgroup password"
|
2002-10-08 20:21:52 +04:00
|
|
|
devdb_cmd="build_devdb"
|
|
|
|
utmp_cmd="build_utmp"
|
2007-05-09 00:33:59 +04:00
|
|
|
services_cmd="build_services"
|
|
|
|
netgroup_cmd="build_netgroup"
|
|
|
|
password_cmd="build_password"
|
|
|
|
echo=:
|
2000-03-10 14:53:23 +03:00
|
|
|
|
|
|
|
sysdb_start()
|
2002-10-08 20:21:52 +04:00
|
|
|
{
|
2007-05-09 00:33:59 +04:00
|
|
|
echo -n "Building databases:"
|
|
|
|
echo=echo
|
|
|
|
comma=" "
|
2003-02-24 04:04:45 +03:00
|
|
|
$devdb_cmd
|
|
|
|
$utmp_cmd
|
2007-05-09 00:33:59 +04:00
|
|
|
$services_cmd
|
|
|
|
$netgroup_cmd
|
|
|
|
$password_cmd
|
|
|
|
echo " done"
|
2002-10-08 20:21:52 +04:00
|
|
|
}
|
|
|
|
|
2007-05-09 00:33:59 +04:00
|
|
|
check_file()
|
2002-10-08 20:21:52 +04:00
|
|
|
{
|
2007-05-09 00:33:59 +04:00
|
|
|
local src="$1"
|
|
|
|
local db="$2"
|
2007-05-13 21:23:56 +04:00
|
|
|
|
2007-05-09 00:33:59 +04:00
|
|
|
shift 2
|
2007-05-16 05:24:42 +04:00
|
|
|
if [ ! -e "$src" ]; then
|
2007-05-13 21:23:56 +04:00
|
|
|
return
|
|
|
|
fi
|
2007-05-09 00:33:59 +04:00
|
|
|
if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
|
|
|
|
$echo -n "$comma$(basename "$src")"
|
|
|
|
comma=", "
|
|
|
|
"$@"
|
2002-10-08 20:21:52 +04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-05-09 00:33:59 +04:00
|
|
|
build_services()
|
|
|
|
{
|
2007-05-10 21:45:50 +04:00
|
|
|
check_file /etc/services /var/db/services.db services_mkdb -q
|
2007-05-09 00:33:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
build_netgroup()
|
|
|
|
{
|
2007-05-10 21:45:50 +04:00
|
|
|
check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb
|
2007-05-09 00:33:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
build_devdb()
|
|
|
|
{
|
|
|
|
check_file /dev /var/run/dev.db dev_mkdb
|
|
|
|
}
|
|
|
|
|
|
|
|
build_password()
|
|
|
|
{
|
|
|
|
local p=/etc/master.passwd
|
2009-06-19 02:00:04 +04:00
|
|
|
check_file $p /etc/spwd.db pwd_mkdb -w $p
|
2007-05-09 00:33:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-08 20:21:52 +04:00
|
|
|
build_utmp()
|
|
|
|
{
|
2002-09-16 06:23:31 +04:00
|
|
|
# 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).
|
2000-07-27 17:58:49 +04:00
|
|
|
#
|
2007-05-09 00:33:59 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-05-13 12:45:06 +04:00
|
|
|
load_rc_config $name
|
2000-03-10 14:53:23 +03:00
|
|
|
run_rc_command "$1"
|