Expand PMF_FN_* macros.
[netbsd-mini2440.git] / etc / rc.d / sysdb
blobcaec852d23df823bfbdab16f386b055ca418e83a
1 #!/bin/sh
3 # $NetBSD: sysdb,v 1.20 2007/08/26 23:55:50 dyoung Exp $
6 # PROVIDE: sysdb
7 # REQUIRE: mountcritremote
8 # BEFORE: DAEMON
10 $_rc_subr_loaded . /etc/rc.subr
12 name="sysdb"
13 rcvar=$name
14 start_cmd="sysdb_start"
15 stop_cmd=":"
16 extra_commands="devdb utmp services netgroup password"
17 devdb_cmd="build_devdb"
18 utmp_cmd="build_utmp"
19 services_cmd="build_services"
20 netgroup_cmd="build_netgroup"
21 password_cmd="build_password"
22 echo=:
24 sysdb_start()
26 echo -n "Building databases:"
27 echo=echo
28 comma=" "
29 $devdb_cmd
30 $utmp_cmd
31 $services_cmd
32 $netgroup_cmd
33 $password_cmd
34 echo " done"
37 check_file()
39 local src="$1"
40 local db="$2"
42 shift 2
43 if [ ! -e "$src" ]; then
44 return
46 if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
47 $echo -n "$comma$(basename "$src")"
48 comma=", "
49 "$@"
53 build_services()
55 check_file /etc/services /var/db/services.db services_mkdb -q
58 build_netgroup()
60 check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb
63 build_devdb()
65 check_file /dev /var/run/dev.db dev_mkdb
68 build_password()
70 local p=/etc/master.passwd
71 check_file $p /etc/spwd.db pwd_mkdb -w $p
74 build_utmp()
76 # Re-create /var/run/utmp and /var/run/utmpx, which are
77 # deleted by mountcritlocal but can't be recreated by it
78 # because install and chown may not be available then
79 # (possibly no /usr).
81 local i
82 for i in "" x; do
83 if [ ! -f /var/run/utmp$i ]; then
84 $echo -n "${comma}utmp$i"
85 comma=", "
86 install -c -m 664 -g utmp /dev/null /var/run/utmp$i
88 done
91 load_rc_config $name
92 run_rc_command "$1"