4 # Required-Start: $remote_fs
5 # Required-Stop: $remote_fs
6 # Default-Start: 2 3 4 5
8 # Short-Description: Starts the Micro Name Service Cache Daemon
9 # Description: This is a daemon which handles passwd and group lookups
10 # for running programs and caches the results for the next
11 # query. You should start this daemon only if you use
12 # slow Services like NIS or NIS+
15 # NB: Because insserv is slightly broken (#606593), we cannot provide
16 # nscd, as this would break installs which hadn't already purged nscd.
17 # However, if you have init scripts which depend on nscd, feel free to
18 # change Provides: unscd to Provides: unscd nscd after purging nscd.
21 # unscd: Starts the Micro Name Service Cache Daemon
23 # description: This is a daemon which handles passwd and group lookups
24 # for running programs and caches the results for the next
25 # query. You should start this daemon only if you use
26 # slow Services like NIS or NIS+
31 DESC="Micro Name Service Cache Daemon"
32 DAEMON="/usr/sbin/nscd"
33 PIDFILE="/var/run/nscd/nscd.pid"
37 [ -f /etc/nscd.conf ] || exit 0
38 [ -x "$DAEMON" ] || exit 0
39 [ -d /var/run/nscd ] || mkdir -p /var/run/nscd
40 . /lib/lsb/init-functions
45 # 0 if daemon has been started
46 # 1 if daemon was already running
47 # 2 if daemon could not be started
48 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 1
49 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" || return 2
55 # 0 if daemon has been stopped
56 # 1 if daemon was already stopped
57 # 2 if daemon could not be stopped
59 # we try to stop using unscd --shutdown, that fails also if unscd is not present.
60 # in that case, fallback to "good old methods"
62 if ! $DAEMON --shutdown; then
63 start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --name "$NAME" --test > /dev/null
65 [ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
68 # Wait for children to finish too
69 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON" > /dev/null
70 [ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
78 # 0 if daemon is stopped
79 # 1 if daemon is running
80 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 1
86 log_daemon_msg "Starting $DESC" "$NAME"
89 0) log_end_msg 0 ; exit 0 ;;
90 1) log_warning_msg " (already running)." ; exit 0 ;;
91 *) log_end_msg 1 ; exit 1 ;;
95 log_daemon_msg "Stopping $DESC" "$NAME"
98 0) log_end_msg 0 ; exit 0 ;;
99 1) log_warning_msg " (not running)." ; exit 0 ;;
100 *) log_end_msg 1 ; exit 1 ;;
103 restart|force-reload|reload)
104 log_daemon_msg "Restarting $DESC" "$NAME"
106 $DAEMON --invalidate passwd --invalidate group --invalidate hosts
111 0) log_end_msg 0 ; exit 0 ;;
112 1) log_failure_msg " (failed -- old process is still running)." ; exit 1 ;;
113 *) log_failure_msg " (failed to start)." ; exit 1 ;;
117 log_failure_msg " (failed to stop)."
123 log_daemon_msg "Status of $DESC service: "
126 0) log_failure_msg "not running." ; exit 1 ;;
127 1) log_success_msg "running." ; exit 0 ;;
131 echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}" >&2