summaryrefslogtreecommitdiff
blob: a683e8fa6444226913940462f1e0ffa47817b1f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nscd,v 1.6 2006/06/18 06:49:50 vapier Exp $

depend() {
	use dns ldap net slapd
}

checkconfig() {
	if [[ ! -d /var/run/nscd ]] ; then
		mkdir -p /var/run/nscd
		chmod 755 /var/run/nscd
	fi
	if [[ -z ${NSCD_PERMS_OK} && $(stat -c %a /var/run/nscd) != "755" ]] ; then
		echo ""
		ewarn "nscd run dir is not world readable, you should reset the perms:"
		ewarn "chmod 755 /var/run/nscd"
		ewarn "chmod a+rw /var/run/nscd/socket"
		echo ""
		ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
		echo ""
	fi
}

start() {
	checkconfig

	ebegin "Starting Name Service Cache Daemon"
	local secure=`while read curline ; do
		table=${curline%:*}
		entries=${curline##$table:}
		table=${table%%[^a-z]*}
		case $table in
			passwd*|group*|hosts)
			for entry in $entries ; do
			case $entry in
				nisplus*)
					/usr/sbin/nscd_nischeck $table || \
					/echo "-S $table,yes"
				;;
			esac
			done
		;;
		esac
		done < /etc/nsswitch.conf`
	local pidfile="$(strings /usr/sbin/nscd | grep nscd.pid)"
	mkdir -p "$(dirname ${pidfile})"
	start-stop-daemon --start --quiet \
		--exec /usr/sbin/nscd --pid ${pidfile} \
		-- $secure
	eend $?
}

stop() {
	ebegin "Shutting down Name Service Cache Daemon"
	start-stop-daemon --stop --quiet --exec /usr/sbin/nscd
	eend $?
}

# vim:ts=4