summaryrefslogtreecommitdiff
path: root/nscd/nscd.init
blob: 572288a2bb1bfb2d1555e7010e01fbbb5bcbfc14 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
# nscd:		Starts the Name Switch Cache Daemon
#
# chkconfig: - 30 80
# description:  This is a daemon which handles passwd and group lookups \
#		for running programs and cache the results for the next \
#		query.  You should start this daemon only if you use \
#		slow Services like NIS or NIS+
# processname: nscd
# config: /etc/nscd.conf
#

# Sanity checks.
[ -f /etc/nscd.conf ] || exit 0
[ -x /usr/sbin/nscd ] || exit 0

# Source function library.
. /etc/rc.d/init.d/functions

# nscd does not run on any kernel lower than 2.2.0 because of threading
# problems, so we require that in first place.
case $(uname -r) in
    2.[2-9].*)
	# this is okay
	;;
    [3-9]*)
	# these are of course also okay
	;;
    *)
	#this is not
	exit 0
	;;
esac

RETVAL=0

# See how we were called.
case "$1" in
    start)
	secure=""
#	for table in passwd group
#	do
#		if egrep '^'$table':.*nisplus' /etc/nsswitch.conf >/dev/null
#		then
#			/usr/lib/nscd_nischeck $table ||
#				secure="$secure -S $table,yes"
#		fi
#	done
        echo -n "Starting Name Switch Cache Daemon: "
	daemon nscd $secure
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
	;;
    stop)
	echo -n "Stopping Name Switch Cache Daemon: "
	/usr/sbin/nscd -K
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		rm -f /var/lock/subsys/nscd
        	echo nscd
	else
		echo
	fi
	;;
  status)
        status nscd
	RETVAL=$?
        ;;
  restart)
        $0 stop
        $0 start
	RETVAL=$?
	;;
  reload)
  	killproc -HUP nscd
	RETVAL=$?
        ;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	;;
esac
exit $RETVAL