Home | History | Annotate | Line # | Download | only in rc.d
sysdb revision 1.16
      1   1.1     lukem #!/bin/sh
      2   1.1     lukem #
      3  1.16  christos # $NetBSD: sysdb,v 1.16 2007/05/08 20:33:59 christos Exp $
      4   1.1     lukem #
      5   1.1     lukem 
      6   1.5     lukem # PROVIDE: sysdb
      7   1.3     lukem # REQUIRE: mountcritremote
      8   1.9   thorpej # BEFORE:  DAEMON
      9   1.1     lukem 
     10  1.14   mycroft $_rc_subr_loaded . /etc/rc.subr
     11   1.1     lukem 
     12   1.1     lukem name="sysdb"
     13   1.1     lukem start_cmd="sysdb_start"
     14   1.1     lukem stop_cmd=":"
     15  1.16  christos extra_commands="devdb utmp services netgroup password"
     16  1.11    atatat devdb_cmd="build_devdb"
     17  1.11    atatat utmp_cmd="build_utmp"
     18  1.16  christos services_cmd="build_services"
     19  1.16  christos netgroup_cmd="build_netgroup"
     20  1.16  christos password_cmd="build_password"
     21  1.16  christos echo=:
     22   1.1     lukem 
     23   1.1     lukem sysdb_start()
     24   1.1     lukem {
     25  1.16  christos 	echo -n "Building databases:"
     26  1.16  christos 	echo=echo
     27  1.16  christos 	comma=" "
     28  1.12    atatat 	$devdb_cmd
     29  1.12    atatat 	$utmp_cmd
     30  1.16  christos 	$services_cmd
     31  1.16  christos 	$netgroup_cmd
     32  1.16  christos 	$password_cmd
     33  1.16  christos 	echo " done"
     34  1.16  christos }
     35  1.16  christos 
     36  1.16  christos check_file()
     37  1.16  christos {
     38  1.16  christos 	local src="$1"
     39  1.16  christos 	local db="$2"
     40  1.16  christos 	shift 2
     41  1.16  christos 	if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
     42  1.16  christos 		$echo -n "$comma$(basename "$src")"
     43  1.16  christos 		comma=", "
     44  1.16  christos 		"$@"
     45  1.16  christos 	fi
     46  1.16  christos }
     47  1.16  christos 
     48  1.16  christos build_services()
     49  1.16  christos {
     50  1.16  christos 	check_file /etc/services /etc/services.db services_mkdb -q
     51  1.16  christos }
     52  1.16  christos 
     53  1.16  christos build_netgroup()
     54  1.16  christos {
     55  1.16  christos 	check_file /etc/netgroup /etc/netgroup.db netgroup_mkdb
     56  1.11    atatat }
     57   1.4     lukem 
     58  1.11    atatat build_devdb()
     59  1.11    atatat {
     60  1.16  christos 	check_file /dev /var/run/dev.db dev_mkdb
     61  1.16  christos }
     62  1.16  christos 
     63  1.16  christos build_password()
     64  1.16  christos {
     65  1.16  christos 	local p=/etc/master.passwd
     66  1.16  christos 	check_file $p /etc/spwd.db pwd_mkdb $p
     67  1.11    atatat }
     68  1.11    atatat 
     69  1.11    atatat build_utmp()
     70  1.11    atatat {
     71  1.10     perry 	#	Re-create /var/run/utmp and /var/run/utmpx, which are
     72  1.10     perry 	#	deleted by mountcritlocal but can't be recreated by it
     73  1.10     perry 	#	because install and chown may not be available then
     74  1.10     perry 	#	(possibly no /usr).
     75   1.4     lukem 	#
     76  1.16  christos 	local i
     77  1.16  christos 	for i in "" x; do
     78  1.16  christos 		if [ ! -f /var/run/utmp$i ]; then
     79  1.16  christos 			$echo -n "${comma}utmp$i"
     80  1.16  christos 			comma=", "
     81  1.16  christos 			install -c -m 664 -g utmp /dev/null /var/run/utmp$i
     82  1.16  christos 		fi
     83  1.16  christos 	done
     84   1.1     lukem }
     85   1.1     lukem 
     86   1.2     lukem load_rc_config $name
     87   1.1     lukem run_rc_command "$1"
     88