2005-02-21 Jakub Jelinek <jakub@redhat.com>
[glibc/history.git] / nscd / nscd.init
blob23e20c3a82ad173347e98060b5f50d50d224bb77
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 [ -d /var/db/nscd ] || mkdir /var/db/nscd
42 secure=""
43 # for table in passwd group hosts
44 # do
45 # if egrep -q '^'$table':.*nisplus' /etc/nsswitch.conf; then
46 # /usr/lib/nscd_nischeck $table || secure="$secure -S $table,yes"
47 # fi
48 # done
49 echo -n $"Starting $prog: "
50 daemon /usr/sbin/nscd $secure
51 RETVAL=$?
52 echo
53 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
54 return $RETVAL
57 stop () {
58 echo -n $"Stopping $prog: "
59 /usr/sbin/nscd -K
60 RETVAL=$?
61 if [ $RETVAL -eq 0 ]; then
62 rm -f /var/lock/subsys/nscd
63 # nscd won't be able to remove these if it is running as
64 # a non-privileged user
65 rm -f /var/run/nscd/nscd.pid
66 rm -f /var/run/nscd/socket
67 success $"$prog shutdown"
68 else
69 failure $"$prog shutdown"
71 echo
72 return $RETVAL
75 restart() {
76 stop
77 start
80 # See how we were called.
81 case "$1" in
82 start)
83 start
84 RETVAL=$?
86 stop)
87 stop
88 RETVAL=$?
90 status)
91 status nscd
92 RETVAL=$?
94 restart)
95 restart
96 RETVAL=$?
98 condrestart)
99 [ -e /var/lock/subsys/nscd ] && restart
100 RETVAL=$?
102 reload)
103 echo -n $"Reloading $prog: "
104 killproc /usr/sbin/nscd -HUP
105 RETVAL=$?
106 echo
109 echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
110 RETVAL=1
112 esac
113 exit $RETVAL