]> git.pld-linux.org Git - packages/glibc.git/blob - nscd.init
- rel 10; update from upstream
[packages/glibc.git] / nscd.init
1 #!/bin/sh
2 #
3 # nscd:         Starts the Name Switch Cache Daemon
4 #
5 # chkconfig:    345 30 80
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 only if you use \
9 #               slow Services like NIS or NIS+
10 # processname:  nscd
11 # config:       /etc/nscd.conf
12 #
13
14 # Sanity checks.
15 [ -f /etc/nscd.conf ] || exit 0
16
17 # Source function library.
18 . /etc/rc.d/init.d/functions
19
20 # Get sysconfig
21 [ -f /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd
22
23 start() {
24         if [ ! -f /var/lock/subsys/nscd ]; then
25                 msg_starting "Name Switch Cache Daemon"
26                 daemon /usr/sbin/nscd
27                 RETVAL=$?
28                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
29         else
30                 msg_already_running "Name Switch Cache Daemon"
31         fi
32 }
33
34 stop() {
35         if [ -f /var/lock/subsys/nscd ]; then
36                 msg_stopping "Name Switch Cache Daemon"
37                 killproc --pidfile /var/run/nscd/nscd.pid nscd -TERM
38                 rm -f /var/lock/subsys/nscd >/dev/null 2>&1
39         else
40                 msg_not_running "Name Switch Cache Daemon"
41         fi
42 }
43
44 condrestart() {
45         if [ -f /var/lock/subsys/nscd ]; then
46                 stop
47                 start
48         else
49                 msg_not_running "Name Switch Cache Daemon"
50                 RETVAL=$1
51         fi
52 }
53
54 RETVAL=0
55 # See how we were called.
56 case "$1" in
57   start)
58         start
59         ;;
60   stop)
61         stop
62         ;;
63   restart)
64         stop
65         start
66         ;;
67   try-restart)
68         condrestart 0
69         ;;
70   force-reload)
71         condrestart 7
72         ;;
73   reload)
74         if [ -f /var/lock/subsys/nscd ]; then
75                 for db in passwd group hosts; do
76                         show "Invalidating %s cache" $db; busy
77                         nscd -i $db && ok || fail
78                 done
79         else
80                 msg_not_running "Name Switch Cache Daemon"
81         fi
82         ;;
83   status)
84         status nscd
85         exit $?
86         ;;
87   *)
88         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
89         exit 3
90 esac
91
92 exit $RETVAL
This page took 0.034501 seconds and 3 git commands to generate.