]>
Commit | Line | Data |
---|---|---|
9fb0fa33 | 1 | #!/bin/sh |
da301058 | 2 | # |
3 | # nscd: Starts the Name Switch Cache Daemon | |
4 | # | |
d0f1f4fa | 5 | # chkconfig: 345 30 80 |
6 | # description: This is a daemon which handles passwd and group lookups \ | |
da301058 | 7 | # for running programs and cache the results for the next \ |
d0f1f4fa | 8 | # query. You should start this daemon only if you use \ |
da301058 | 9 | # slow Services like NIS or NIS+ |
d0f1f4fa | 10 | # processname: nscd |
11 | # config: /etc/nscd.conf | |
da301058 | 12 | # |
13 | ||
14 | # Sanity checks. | |
15 | [ -f /etc/nscd.conf ] || exit 0 | |
da301058 | 16 | |
17 | # Source function library. | |
18 | . /etc/rc.d/init.d/functions | |
19 | ||
02156a25 | 20 | # Get sysconfig |
d0f1f4fa | 21 | [ -f /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd |
e4a5a03a | 22 | |
86431a2c | 23 | start() { |
d0f1f4fa | 24 | if [ ! -f /var/lock/subsys/nscd ]; then |
bec6c405 | 25 | msg_starting "Name Switch Cache Daemon" |
7d9bb8d7 | 26 | daemon /usr/sbin/nscd |
d0f1f4fa | 27 | RETVAL=$? |
28 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd | |
29 | else | |
fc29e4cb | 30 | msg_already_running "Name Switch Cache Daemon" |
d0f1f4fa | 31 | fi |
86431a2c ER |
32 | } |
33 | ||
34 | stop() { | |
d0f1f4fa | 35 | if [ -f /var/lock/subsys/nscd ]; then |
36 | msg_stopping "Name Switch Cache Daemon" | |
37 | busy | |
38 | /usr/sbin/nscd -K | |
39 | rm -f /var/lock/subsys/nscd >/dev/null 2>&1 | |
d0f1f4fa | 40 | ok |
41 | else | |
fc29e4cb | 42 | msg_not_running "Name Switch Cache Daemon" |
5d4ed5ed | 43 | fi |
86431a2c ER |
44 | } |
45 | ||
6615b296 JB |
46 | condrestart() { |
47 | if [ -f /var/lock/subsys/nscd ]; then | |
48 | stop | |
49 | start | |
50 | else | |
51 | msg_not_running "Name Switch Cache Daemon" | |
52 | RETVAL=$1 | |
53 | fi | |
54 | } | |
55 | ||
86431a2c ER |
56 | RETVAL=0 |
57 | # See how we were called. | |
58 | case "$1" in | |
59 | start) | |
6615b296 | 60 | start |
86431a2c ER |
61 | ;; |
62 | stop) | |
6615b296 | 63 | stop |
da301058 | 64 | ;; |
6615b296 JB |
65 | restart) |
66 | stop | |
67 | start | |
68 | ;; | |
69 | try-restart) | |
70 | condrestart 0 | |
71 | ;; | |
72 | force-reload) | |
73 | condrestart 7 | |
e4a5a03a | 74 | ;; |
57da80b1 | 75 | reload) |
4e3bda50 | 76 | if [ -f /var/lock/subsys/nscd ]; then |
2d954354 ER |
77 | for db in passwd group hosts; do |
78 | show "Invalidating %s cache" $db; busy | |
79 | nscd -i $db && ok || fail | |
80 | done | |
81 | else | |
82 | msg_not_running "Name Switch Cache Daemon" | |
83 | fi | |
57da80b1 | 84 | ;; |
6615b296 JB |
85 | status) |
86 | status nscd | |
87 | exit $? | |
e4a5a03a | 88 | ;; |
89 | *) | |
6615b296 | 90 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" |
2db0604a | 91 | exit 3 |
da301058 | 92 | esac |
d0f1f4fa | 93 | |
94 | exit $RETVAL |