]> git.pld-linux.org Git - packages/glibc.git/blob - nscd.init
- skip reload if service is down
[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 [ -x /usr/sbin/nscd ] || exit 0
17
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20
21 # Get sysconfig
22 [ -f /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd
23
24 start() {
25         if [ ! -f /var/lock/subsys/nscd ]; then
26                 msg_starting "Name Switch Cache Daemon"
27                 daemon nscd
28                 RETVAL=$?
29                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
30         else
31                 msg_already_running "Name Switch Cache Daemon"
32         fi
33 }
34
35 stop() {
36         if [ -f /var/lock/subsys/nscd ]; then
37                 msg_stopping "Name Switch Cache Daemon"
38                 busy
39                 /usr/sbin/nscd -K
40                 rm -f /var/lock/subsys/nscd >/dev/null 2>&1
41                 ok
42         else
43                 msg_not_running "Name Switch Cache Daemon"
44         fi
45 }
46
47 RETVAL=0
48 # See how we were called.
49 case "$1" in
50   start)
51         start
52         ;;
53   stop)
54         stop
55         ;;
56   status)
57         status nscd
58         exit $?
59         ;;
60   reload)
61         if [ -f /var/lock/subsys/nscd ]; then
62                 for db in passwd group hosts; do
63                         show "Invalidating %s cache" $db; busy
64                         nscd -i $db && ok || fail
65                 done
66         else
67                 msg_not_running "Name Switch Cache Daemon"
68         fi
69         ;;
70   restart|force-reload)
71         stop
72         start
73         ;;
74   *)
75         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
76         exit 3
77 esac
78
79 exit $RETVAL
This page took 0.106948 seconds and 4 git commands to generate.