[BACK]Return to sysdb CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / sysdb (download)

Revision 1.25, Sat Apr 23 21:24:31 2016 UTC (2 years, 10 months ago) by dholland
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, HEAD
Changes since 1.24: +2 -2 lines

Avoid unnecessary use of basename(1). From Jukka Salmi a long, long time
ago on a tech-kern far, far away.

#!/bin/sh
#
# $NetBSD: sysdb,v 1.25 2016/04/23 21:24:31 dholland Exp $
#

# PROVIDE: sysdb
# REQUIRE: mountcritremote
# BEFORE:  DAEMON

$_rc_subr_loaded . /etc/rc.subr

name="sysdb"
rcvar=$name
start_cmd="sysdb_start"
stop_cmd=":"
extra_commands="devdb utmp services netgroup password"
devdb_cmd="build_devdb"
utmp_cmd="build_utmp"
services_cmd="build_services"
netgroup_cmd="build_netgroup"
password_cmd="build_password"
echo=:

sysdb_start()
{
	echo -n "Building databases:"
	echo=echo
	comma=" "
	$devdb_cmd
	$utmp_cmd
	$services_cmd
	$netgroup_cmd
	$password_cmd
	echo "."
}

check_file()
{
	local src="$1"
	local db="$2"

	shift 2
	if [ ! -e "$src" ]; then
		return
	fi
	if [ \( ! -f "$db" \) -o \( "$src" -nt "$db" \) ]; then
		$echo -n "$comma${src##*/}"
		comma=", "
		"$@"
	fi
}

build_services()
{
	check_file /etc/services /var/db/services.cdb services_mkdb -q
}

build_netgroup()
{
	check_file /etc/netgroup /var/db/netgroup.db netgroup_mkdb
}

build_devdb()
{
	check_file /dev /var/run/dev.db dev_mkdb
	check_file /dev /var/run/dev.cdb dev_mkdb
}

build_password()
{
	local p=/etc/master.passwd
	check_file $p /etc/spwd.db pwd_mkdb -w $p
}

build_utmp()
{
	#	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).
	#
	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
}

load_rc_config $name
run_rc_command "$1"