Home | History | Annotate | Line # | Download | only in rc.d
sysdb revision 1.22.2.1
      1       1.1     lukem #!/bin/sh
      2       1.1     lukem #
      3  1.22.2.1      yamt # $NetBSD: sysdb,v 1.22.2.1 2012/04/17 00:02:59 yamt 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.20    dyoung rcvar=$name
     14       1.1     lukem start_cmd="sysdb_start"
     15       1.1     lukem stop_cmd=":"
     16      1.16  christos extra_commands="devdb utmp services netgroup password"
     17      1.11    atatat devdb_cmd="build_devdb"
     18      1.11    atatat utmp_cmd="build_utmp"
     19      1.16  christos services_cmd="build_services"
     20      1.16  christos netgroup_cmd="build_netgroup"
     21      1.16  christos password_cmd="build_password"
     22      1.16  christos echo=:
     23       1.1     lukem 
     24       1.1     lukem sysdb_start()
     25       1.1     lukem {
     26      1.16  christos 	echo -n "Building databases:"
     27      1.16  christos 	echo=echo
     28      1.16  christos 	comma=" "
     29      1.12    atatat 	$devdb_cmd
     30      1.12    atatat 	$utmp_cmd
     31      1.16  christos 	$services_cmd
     32      1.16  christos 	$netgroup_cmd
     33      1.16  christos 	$password_cmd
     34      1.22   mbalmer 	echo "."
     35      1.16  christos }
     36      1.16  christos 
     37      1.16  christos check_file()
     38      1.16  christos {
     39      1.16  christos 	local src="$1"
     40      1.16  christos 	local db="$2"
     41      1.18  christos 
     42      1.16  christos 	shift 2
     43      1.19  christos 	if [ ! -e "$src" ]; then
     44      1.18  christos 		return
     45      1.18  christos 	fi
     46      1.16  christos 	if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
     47      1.16  christos 		$echo -n "$comma$(basename "$src")"
     48      1.16  christos 		comma=", "
     49      1.16  christos 		"$@"
     50      1.16  christos 	fi
     51      1.16  christos }
     52      1.16  christos 
     53      1.16  christos build_services()
     54      1.16  christos {
     55  1.22.2.1      yamt 	check_file /etc/services /var/db/services.cdb services_mkdb -q
     56      1.16  christos }
     57      1.16  christos 
     58      1.16  christos build_netgroup()
     59      1.16  christos {
     60      1.17  christos 	check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb
     61      1.11    atatat }
     62       1.4     lukem 
     63      1.11    atatat build_devdb()
     64      1.11    atatat {
     65      1.16  christos 	check_file /dev /var/run/dev.db dev_mkdb
     66      1.16  christos }
     67      1.16  christos 
     68      1.16  christos build_password()
     69      1.16  christos {
     70      1.16  christos 	local p=/etc/master.passwd
     71      1.21  christos 	check_file $p /etc/spwd.db pwd_mkdb -w $p
     72      1.11    atatat }
     73      1.11    atatat 
     74      1.11    atatat build_utmp()
     75      1.11    atatat {
     76      1.10     perry 	#	Re-create /var/run/utmp and /var/run/utmpx, which are
     77      1.10     perry 	#	deleted by mountcritlocal but can't be recreated by it
     78      1.10     perry 	#	because install and chown may not be available then
     79      1.10     perry 	#	(possibly no /usr).
     80       1.4     lukem 	#
     81      1.16  christos 	local i
     82      1.16  christos 	for i in "" x; do
     83      1.16  christos 		if [ ! -f /var/run/utmp$i ]; then
     84      1.16  christos 			$echo -n "${comma}utmp$i"
     85      1.16  christos 			comma=", "
     86      1.16  christos 			install -c -m 664 -g utmp /dev/null /var/run/utmp$i
     87      1.16  christos 		fi
     88      1.16  christos 	done
     89       1.1     lukem }
     90       1.1     lukem 
     91       1.2     lukem load_rc_config $name
     92       1.1     lukem run_rc_command "$1"
     93