]> git.pld-linux.org Git - packages/unscd.git/blame - nscd.init
add pidfile to status
[packages/unscd.git] / nscd.init
CommitLineData
ba37f5e7 1#!/bin/sh
1210f8df 2#
3# nscd: Starts the Name Switch Cache Daemon
4#
9c888ea1 5# chkconfig: 345 30 80
6# description: This is a daemon which handles passwd and group lookups \
1210f8df 7# for running programs and cache the results for the next \
9c888ea1 8# query. You should start this daemon only if you use \
1210f8df 9# slow Services like NIS or NIS+
9c888ea1 10# processname: nscd
11# config: /etc/nscd.conf
f87ccbf9 12# pidfile: /var/run/nscd/nscd.pid
1210f8df 13#
14
15# Sanity checks.
16[ -f /etc/nscd.conf ] || exit 0
1210f8df 17
18# Source function library.
19. /etc/rc.d/init.d/functions
20
71c39fad 21# Get sysconfig
9c888ea1 22[ -f /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd
0d609f55 23
dbe39949 24start() {
6a339a06 25 if [ -f /var/lock/subsys/nscd ]; then
51a5deba 26 msg_already_running "Name Switch Cache Daemon"
6a339a06 27 return
9c888ea1 28 fi
6a339a06
ER
29
30 msg_starting "Name Switch Cache Daemon"
31 daemon /usr/sbin/nscd
32 RETVAL=$?
33 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
dbe39949
ER
34}
35
36stop() {
6a339a06 37 if [ ! -f /var/lock/subsys/nscd ]; then
51a5deba 38 msg_not_running "Name Switch Cache Daemon"
6a339a06 39 return
3e2271b8 40 fi
6a339a06
ER
41
42 msg_stopping "Name Switch Cache Daemon"
43 busy
44 /usr/sbin/nscd -K >/dev/null
45 rm -f /var/lock/subsys/nscd >/dev/null 2>&1
46 ok
dbe39949
ER
47}
48
e29c4d27 49condrestart() {
6a339a06 50 if [ ! -f /var/lock/subsys/nscd ]; then
e29c4d27
JB
51 msg_not_running "Name Switch Cache Daemon"
52 RETVAL=$1
6a339a06 53 return
e29c4d27 54 fi
6a339a06
ER
55
56 stop
57 start
e29c4d27
JB
58}
59
68b1551a 60# return true if service is considered "up"
68b1551a
ER
61# otherwise lockfile in subsys must exist
62is_service_up() {
5456b713 63 [ -f /var/lock/subsys/"$1" ]
68b1551a
ER
64}
65
dbe39949
ER
66RETVAL=0
67# See how we were called.
68case "$1" in
69 start)
e29c4d27 70 start
dbe39949
ER
71 ;;
72 stop)
e29c4d27 73 stop
1210f8df 74 ;;
e29c4d27
JB
75 restart)
76 stop
77 start
78 ;;
79 try-restart)
80 condrestart 0
81 ;;
ad894a1c 82 reload|force-reload)
68b1551a 83 if is_service_up nscd; then
a75a6af1
ER
84 for db in passwd group hosts; do
85 show "Invalidating %s cache" $db; busy
4be8a738 86 nscd -i $db >/dev/null && ok || fail
a75a6af1
ER
87 done
88 else
89 msg_not_running "Name Switch Cache Daemon"
90 fi
bc42fd82 91 ;;
e29c4d27
JB
92 status)
93 status nscd
f87ccbf9 94 status --pidfile /var/run/nscd/nscd.pid nscd
e29c4d27 95 exit $?
0d609f55 96 ;;
97 *)
e29c4d27 98 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
297e48d6 99 exit 3
1210f8df 100esac
9c888ea1 101
102exit $RETVAL
This page took 0.123138 seconds and 4 git commands to generate.