4
# Required-Start: $remote_fs $syslog
5
# Required-Stop: $remote_fs $syslog
6
# Default-Start: 2 3 4 5
8
# Short-Description: Starts the Name Service Cache Daemon
12
# nscd: Starts the Name Service Cache Daemon
14
# description: This is a daemon which handles passwd and group lookups
15
# for running programs and caches the results for the next
16
# query. You should start this daemon only if you use
17
# slow Services like NIS or NIS+
19
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
21
DESC="Name Service Cache Daemon"
22
DAEMON="/usr/sbin/nscd"
23
PIDFILE="/var/run/nscd/nscd.pid"
27
[ -f /etc/nscd.conf ] || exit 0
28
[ -x "$DAEMON" ] || exit 0
29
[ -d /var/run/nscd ] || mkdir -p /var/run/nscd
30
. /lib/lsb/init-functions
35
# 0 if daemon has been started or was already running
36
# 2 if daemon could not be started
37
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 0
38
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" || return 2
44
# 0 if daemon has been stopped
45
# 1 if daemon was already stopped
46
# 2 if daemon could not be stopped
48
# we try to stop using nscd --shutdown, that fails also if nscd is not present.
49
# in that case, fallback to "good old methods"
51
if ! $DAEMON --shutdown; then
52
start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --name "$NAME" --test > /dev/null
54
[ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
57
# Wait for children to finish too
58
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON" > /dev/null
59
[ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
67
# 0 if daemon is stopped
68
# 1 if daemon is running
69
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 1
75
for table in passwd group hosts ; do
76
$DAEMON --invalidate $table
82
log_daemon_msg "Starting $DESC" "$NAME"
85
0) invalidate_cache ; log_end_msg 0 ; exit 0 ;;
86
1) log_warning_msg " (already running)." ; exit 0 ;;
87
*) log_end_msg 1 ; exit 1 ;;
91
log_daemon_msg "Stopping $DESC" "$NAME"
94
0) log_end_msg 0 ; exit 0 ;;
95
1) log_warning_msg " (not running)." ; exit 0 ;;
96
*) log_end_msg 1 ; exit 1 ;;
100
log_daemon_msg "Restarting $DESC" "$NAME"
107
0) log_end_msg 0 ; exit 0 ;;
108
1) log_failure_msg " (failed -- old process is still running)." ; exit 1 ;;
109
*) log_failure_msg " (failed to start)." ; exit 1 ;;
113
log_failure_msg " (failed to stop)."
119
log_daemon_msg "Status of $DESC service: "
122
0) log_failure_msg "not running." ; exit 3 ;;
123
1) log_success_msg "running." ; exit 0 ;;
127
echo "Usage: /etc/init.d/$NAME {start|stop|force-reload|restart|status}" >&2