]>
Commit | Line | Data |
---|---|---|
520ec963 | 1 | #!/bin/bash |
d67281a7 UD |
2 | # |
3 | # nscd: Starts the Name Switch Cache Daemon | |
4 | # | |
520ec963 | 5 | # chkconfig: - 30 74 |
ac72fbb1 UD |
6 | # description: This is a daemon which handles passwd and group lookups \ |
7 | # for running programs and cache the results for the next \ | |
520ec963 UD |
8 | # query. You should start this daemon if you use \ |
9 | # slow naming services like NIS, NIS+, LDAP, or hesiod. | |
10 | # processname: /usr/sbin/nscd | |
ac72fbb1 UD |
11 | # config: /etc/nscd.conf |
12 | # | |
64d64de6 UD |
13 | ### BEGIN INIT INFO |
14 | # Provides: nscd | |
15 | # Required-Start: $syslog | |
16 | # Default-Stop: 0 1 6 | |
17 | # Short-Description: Starts the Name Switch Cache Daemon | |
18 | # Description: This is a daemon which handles passwd and group lookups \ | |
19 | # for running programs and cache the results for the next \ | |
20 | # query. You should start this daemon if you use \ | |
21 | # slow naming services like NIS, NIS+, LDAP, or hesiod. | |
22 | ### END INIT INFO | |
ac72fbb1 UD |
23 | |
24 | # Sanity checks. | |
25 | [ -f /etc/nscd.conf ] || exit 0 | |
26 | [ -x /usr/sbin/nscd ] || exit 0 | |
d67281a7 UD |
27 | |
28 | # Source function library. | |
520ec963 | 29 | . /etc/init.d/functions |
d67281a7 | 30 | |
a334319f UD |
31 | # nscd does not run on any kernel lower than 2.2.0 because of threading |
32 | # problems, so we require that in first place. | |
33 | case $(uname -r) in | |
34 | 2.[2-9].*) | |
35 | # this is okay | |
36 | ;; | |
37 | [3-9]*) | |
38 | # these are of course also okay | |
39 | ;; | |
40 | *) | |
41 | #this is not | |
64d64de6 | 42 | exit 1 |
a334319f UD |
43 | ;; |
44 | esac | |
aa6adf82 UD |
45 | |
46 | RETVAL=0 | |
520ec963 UD |
47 | prog=nscd |
48 | ||
49 | start () { | |
50 | [ -d /var/run/nscd ] || mkdir /var/run/nscd | |
457962e5 | 51 | [ -d /var/db/nscd ] || mkdir /var/db/nscd |
520ec963 | 52 | echo -n $"Starting $prog: " |
11bf311e | 53 | daemon /usr/sbin/nscd |
520ec963 UD |
54 | RETVAL=$? |
55 | echo | |
56 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd | |
57 | return $RETVAL | |
58 | } | |
59 | ||
60 | stop () { | |
61 | echo -n $"Stopping $prog: " | |
62 | /usr/sbin/nscd -K | |
63 | RETVAL=$? | |
64 | if [ $RETVAL -eq 0 ]; then | |
65 | rm -f /var/lock/subsys/nscd | |
66 | # nscd won't be able to remove these if it is running as | |
67 | # a non-privileged user | |
68 | rm -f /var/run/nscd/nscd.pid | |
aadd7d9d | 69 | rm -f /var/run/nscd/socket |
520ec963 UD |
70 | success $"$prog shutdown" |
71 | else | |
72 | failure $"$prog shutdown" | |
73 | fi | |
74 | echo | |
75 | return $RETVAL | |
76 | } | |
77 | ||
78 | restart() { | |
79 | stop | |
80 | start | |
81 | } | |
aa6adf82 | 82 | |
d67281a7 UD |
83 | # See how we were called. |
84 | case "$1" in | |
85 | start) | |
520ec963 | 86 | start |
aa6adf82 | 87 | RETVAL=$? |
d67281a7 UD |
88 | ;; |
89 | stop) | |
520ec963 | 90 | stop |
aa6adf82 | 91 | RETVAL=$? |
d67281a7 | 92 | ;; |
520ec963 | 93 | status) |
58954d49 | 94 | status nscd |
aa6adf82 | 95 | RETVAL=$? |
58954d49 | 96 | ;; |
520ec963 UD |
97 | restart) |
98 | restart | |
99 | RETVAL=$? | |
100 | ;; | |
64d64de6 | 101 | try-restart | condrestart) |
520ec963 | 102 | [ -e /var/lock/subsys/nscd ] && restart |
aa6adf82 UD |
103 | RETVAL=$? |
104 | ;; | |
64d64de6 | 105 | force-reload | reload) |
58954d49 RM |
106 | echo -n $"Reloading $prog: " |
107 | killproc /usr/sbin/nscd -HUP | |
aa6adf82 | 108 | RETVAL=$? |
58954d49 RM |
109 | echo |
110 | ;; | |
d67281a7 | 111 | *) |
520ec963 UD |
112 | echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" |
113 | RETVAL=1 | |
d67281a7 UD |
114 | ;; |
115 | esac | |
aa6adf82 | 116 | exit $RETVAL |