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