1 1.1 lukem #!/bin/sh 2 1.1 lukem # 3 1.18 christos # $NetBSD: sysdb,v 1.18 2007/05/13 17:23:56 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.18 christos 41 1.16 christos shift 2 42 1.18 christos if [ ! -f "$src" ]; then 43 1.18 christos return 44 1.18 christos fi 45 1.16 christos if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then 46 1.16 christos $echo -n "$comma$(basename "$src")" 47 1.16 christos comma=", " 48 1.16 christos "$@" 49 1.16 christos fi 50 1.16 christos } 51 1.16 christos 52 1.16 christos build_services() 53 1.16 christos { 54 1.17 christos check_file /etc/services /var/db/services.db services_mkdb -q 55 1.16 christos } 56 1.16 christos 57 1.16 christos build_netgroup() 58 1.16 christos { 59 1.17 christos check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb 60 1.11 atatat } 61 1.4 lukem 62 1.11 atatat build_devdb() 63 1.11 atatat { 64 1.16 christos check_file /dev /var/run/dev.db dev_mkdb 65 1.16 christos } 66 1.16 christos 67 1.16 christos build_password() 68 1.16 christos { 69 1.16 christos local p=/etc/master.passwd 70 1.16 christos check_file $p /etc/spwd.db pwd_mkdb $p 71 1.11 atatat } 72 1.11 atatat 73 1.11 atatat build_utmp() 74 1.11 atatat { 75 1.10 perry # Re-create /var/run/utmp and /var/run/utmpx, which are 76 1.10 perry # deleted by mountcritlocal but can't be recreated by it 77 1.10 perry # because install and chown may not be available then 78 1.10 perry # (possibly no /usr). 79 1.4 lukem # 80 1.16 christos local i 81 1.16 christos for i in "" x; do 82 1.16 christos if [ ! -f /var/run/utmp$i ]; then 83 1.16 christos $echo -n "${comma}utmp$i" 84 1.16 christos comma=", " 85 1.16 christos install -c -m 664 -g utmp /dev/null /var/run/utmp$i 86 1.16 christos fi 87 1.16 christos done 88 1.1 lukem } 89 1.1 lukem 90 1.2 lukem load_rc_config $name 91 1.1 lukem run_rc_command "$1" 92