xref: /freebsd/libexec/rc/rc.d/nscd (revision a4e5e0106ac7145f56eb39a691e302cabb4635be)
1#!/bin/sh
2#
3#
4
5# PROVIDE: nscd
6# REQUIRE: DAEMON
7# BEFORE: LOGIN
8# KEYWORD: shutdown
9
10#
11# Add the following lines to /etc/rc.conf to enable nscd:
12#
13# nscd_enable="YES"
14#
15# See nscd(8) for flags
16#
17
18. /etc/rc.subr
19
20name="nscd"
21desc="Name-service caching daemon"
22rcvar="nscd_enable"
23
24command=/usr/sbin/nscd
25extra_commands="flush"
26flush_cmd="${command} -I all"
27
28# usage: _nscd_set_option <option name> <default value>
29#
30_nscd_set_option() {
31	local _optname _defoptval _nscd_opt_val _cached_opt_val
32	_optname=$1
33	_defoptval=$2
34
35	_nscd_opt_val=$(eval "echo \$nscd_${_optname}")
36	_cached_opt_val=$(eval "echo \$cached_${_optname}")
37
38	if [ -n "$_cached_opt_val" -a "$_nscd_opt_val" != "$_defoptval" ]; then
39		warn "You should use nscd_${_optname} instead of" \
40		    "cached_${_optname}"
41		setvar "nscd_${_optname}" "$_cached_opt_val"
42	else
43		setvar "nscd_${_optname}" "${_nscd_opt_val:-$_defoptval}"
44	fi
45}
46
47
48load_rc_config $name
49_nscd_set_option "enable" "NO"
50_nscd_set_option "pidfile" "/var/run/nscd.pid"
51_nscd_set_option "flags" ""
52run_rc_command "$1"
53
54