(nscd_run): Check early for invalid request types.
[glibc.git] / nscd / nscd.init
blob3796b3d0a099f3866276e7d0e99fd6619a3ce81a
1 #!/bin/bash
3 # nscd: Starts the Name Switch Cache Daemon
5 # chkconfig: - 30 74
6 # description: This is a daemon which handles passwd and group lookups \
7 # for running programs and cache the results for the next \
8 # query. You should start this daemon if you use \
9 # slow naming services like NIS, NIS+, LDAP, or hesiod.
10 # processname: /usr/sbin/nscd
11 # config: /etc/nscd.conf
14 # Sanity checks.
15 [ -f /etc/nscd.conf ] || exit 0
16 [ -x /usr/sbin/nscd ] || exit 0
18 # Source function library.
19 . /etc/init.d/functions
21 # nscd does not run on any kernel lower than 2.2.0 because of threading
22 # problems, so we require that in first place.
23 case $(uname -r) in
24 2.[2-9].*)
25 # this is okay
27 [3-9]*)
28 # these are of course also okay
31 #this is not
32 exit 0
34 esac
36 RETVAL=0
37 prog=nscd
39 start () {
40 [ -d /var/run/nscd ] || mkdir /var/run/nscd
41 secure=""
42 # for table in passwd group hosts
43 # do
44 # if egrep -q '^'$table':.*nisplus' /etc/nsswitch.conf; then
45 # /usr/lib/nscd_nischeck $table || secure="$secure -S $table,yes"
46 # fi
47 # done
48 echo -n $"Starting $prog: "
49 daemon /usr/sbin/nscd $secure
50 RETVAL=$?
51 echo
52 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
53 return $RETVAL
56 stop () {
57 echo -n $"Stopping $prog: "
58 /usr/sbin/nscd -K
59 RETVAL=$?
60 if [ $RETVAL -eq 0 ]; then
61 rm -f /var/lock/subsys/nscd
62 # nscd won't be able to remove these if it is running as
63 # a non-privileged user
64 rm -f /var/run/nscd/nscd.pid
65 rm -f /var/run/nscd/.socket
66 success $"$prog shutdown"
67 else
68 failure $"$prog shutdown"
70 echo
71 return $RETVAL
74 restart() {
75 stop
76 start
79 # See how we were called.
80 case "$1" in
81 start)
82 start
83 RETVAL=$?
85 stop)
86 stop
87 RETVAL=$?
89 status)
90 status nscd
91 RETVAL=$?
93 restart)
94 restart
95 RETVAL=$?
97 condrestart)
98 [ -e /var/lock/subsys/nscd ] && restart
99 RETVAL=$?
101 reload)
102 killproc /usr/sbin/nscd -HUP
103 RETVAL=$?
106 echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
107 RETVAL=1
109 esac
110 exit $RETVAL