.
[glibc.git] / nscd / nscd.init
bloba0074b99e5a113da829f00b3078d124f8e086a01
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
13 ### BEGIN INIT INFO
14 # Provides: nscd
15 # Required-Start: $syslog
16 # Default-Stop: 0 1 6
17 # Short-Description: Starts the Name Switch Cache Daemon
18 # Description: This is a daemon which handles passwd and group lookups \
19 # for running programs and cache the results for the next \
20 # query. You should start this daemon if you use \
21 # slow naming services like NIS, NIS+, LDAP, or hesiod.
22 ### END INIT INFO
24 # Sanity checks.
25 [ -f /etc/nscd.conf ] || exit 0
26 [ -x /usr/sbin/nscd ] || exit 0
28 # Source function library.
29 . /etc/init.d/functions
31 # nscd does not run on any kernel lower than 2.2.0 because of threading
32 # problems, so we require that in first place.
33 case $(uname -r) in
34 2.[2-9].*)
35 # this is okay
37 [3-9]*)
38 # these are of course also okay
41 #this is not
42 exit 1
44 esac
46 RETVAL=0
47 prog=nscd
49 start () {
50 [ -d /var/run/nscd ] || mkdir /var/run/nscd
51 [ -d /var/db/nscd ] || mkdir /var/db/nscd
52 secure=""
53 # for table in passwd group hosts
54 # do
55 # if egrep -q '^'$table':.*nisplus' /etc/nsswitch.conf; then
56 # /usr/lib/nscd_nischeck $table || secure="$secure -S $table,yes"
57 # fi
58 # done
59 echo -n $"Starting $prog: "
60 daemon /usr/sbin/nscd $secure
61 RETVAL=$?
62 echo
63 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
64 return $RETVAL
67 stop () {
68 echo -n $"Stopping $prog: "
69 /usr/sbin/nscd -K
70 RETVAL=$?
71 if [ $RETVAL -eq 0 ]; then
72 rm -f /var/lock/subsys/nscd
73 # nscd won't be able to remove these if it is running as
74 # a non-privileged user
75 rm -f /var/run/nscd/nscd.pid
76 rm -f /var/run/nscd/socket
77 success $"$prog shutdown"
78 else
79 failure $"$prog shutdown"
81 echo
82 return $RETVAL
85 restart() {
86 stop
87 start
90 # See how we were called.
91 case "$1" in
92 start)
93 start
94 RETVAL=$?
96 stop)
97 stop
98 RETVAL=$?
100 status)
101 status nscd
102 RETVAL=$?
104 restart)
105 restart
106 RETVAL=$?
108 try-restart | condrestart)
109 [ -e /var/lock/subsys/nscd ] && restart
110 RETVAL=$?
112 force-reload | reload)
113 echo -n $"Reloading $prog: "
114 killproc /usr/sbin/nscd -HUP
115 RETVAL=$?
116 echo
119 echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
120 RETVAL=1
122 esac
123 exit $RETVAL