]> git.pld-linux.org Git - packages/glibc.git/blob - nscd.init
75725ef886f239282dd9b7ecad72af2478636652
[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 condrestart() {
48         if [ -f /var/lock/subsys/nscd ]; then
49                 stop
50                 start
51         else
52                 msg_not_running "Name Switch Cache Daemon"
53                 RETVAL=$1
54         fi
55 }
56
57 RETVAL=0
58 # See how we were called.
59 case "$1" in
60   start)
61         start
62         ;;
63   stop)
64         stop
65         ;;
66   restart)
67         stop
68         start
69         ;;
70   try-restart)
71         condrestart 0
72         ;;
73   force-reload)
74         condrestart 7
75         ;;
76   reload)
77         if [ -f /var/lock/subsys/nscd ]; then
78                 for db in passwd group hosts; do
79                         show "Invalidating %s cache" $db; busy
80                         nscd -i $db && ok || fail
81                 done
82         else
83                 msg_not_running "Name Switch Cache Daemon"
84         fi
85         ;;
86   status)
87         status nscd
88         exit $?
89         ;;
90   *)
91         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
92         exit 3
93 esac
94
95 exit $RETVAL
This page took 0.029773 seconds and 3 git commands to generate.