]>
Commit | Line | Data |
---|---|---|
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 | busy | |
38 | /usr/sbin/nscd -K | |
39 | rm -f /var/lock/subsys/nscd >/dev/null 2>&1 | |
40 | ok | |
41 | else | |
42 | msg_not_running "Name Switch Cache Daemon" | |
43 | fi | |
44 | } | |
45 | ||
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 | ||
56 | upstart_controlled --except reload | |
57 | ||
58 | # return true if service is considered "up" | |
59 | # with upstart, upstart is consulted | |
60 | # otherwise lockfile in subsys must exist | |
61 | is_service_up() { | |
62 | use_upstart && is_upstart_running "$1" || [ -f /var/lock/subsys/"$1" ] | |
63 | } | |
64 | ||
65 | RETVAL=0 | |
66 | # See how we were called. | |
67 | case "$1" in | |
68 | start) | |
69 | start | |
70 | ;; | |
71 | stop) | |
72 | stop | |
73 | ;; | |
74 | restart) | |
75 | stop | |
76 | start | |
77 | ;; | |
78 | try-restart) | |
79 | condrestart 0 | |
80 | ;; | |
81 | force-reload) | |
82 | condrestart 7 | |
83 | ;; | |
84 | reload) | |
85 | if is_service_up nscd; then | |
86 | for db in passwd group hosts; do | |
87 | show "Invalidating %s cache" $db; busy | |
88 | nscd -i $db && ok || fail | |
89 | done | |
90 | else | |
91 | msg_not_running "Name Switch Cache Daemon" | |
92 | fi | |
93 | ;; | |
94 | status) | |
95 | status nscd | |
96 | exit $? | |
97 | ;; | |
98 | *) | |
99 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" | |
100 | exit 3 | |
101 | esac | |
102 | ||
103 | exit $RETVAL |