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
12 # unscd: Starts the Micro 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+
22 DESC="Micro Name Service Cache Daemon"
23 DAEMON="/usr/sbin/nscd"
24 PIDFILE="/var/run/nscd/nscd.pid"
28 [ -f /etc/nscd.conf ] || exit 0
29 [ -x "$DAEMON" ] || exit 0
30 [ -d /var/run/nscd ] || mkdir -p /var/run/nscd
31 . /lib/lsb/init-functions
36 # 0 if daemon has been started
37 # 1 if daemon was already running
38 # 2 if daemon could not be started
39 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 1
40 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" || return 2
46 # 0 if daemon has been stopped
47 # 1 if daemon was already stopped
48 # 2 if daemon could not be stopped
50 # we try to stop using unscd --shutdown, that fails also if unscd is not present.
51 # in that case, fallback to "good old methods"
53 if ! $DAEMON --shutdown; then
54 start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --name "$NAME" --test > /dev/null
56 [ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
59 # Wait for children to finish too
60 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON" > /dev/null
61 [ "$?" -ne 0 -a "$?" -ne 1 ] && return 2
69 # 0 if daemon is stopped
70 # 1 if daemon is running
71 start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null || return 1
77 log_daemon_msg "Starting $DESC" "$NAME"
80 0) log_end_msg 0 ; exit 0 ;;
81 1) log_warning_msg " (already running)." ; exit 0 ;;
82 *) log_end_msg 1 ; exit 1 ;;
86 log_daemon_msg "Stopping $DESC" "$NAME"
89 0) log_end_msg 0 ; exit 0 ;;
90 1) log_warning_msg " (not running)." ; exit 0 ;;
91 *) log_end_msg 1 ; exit 1 ;;
94 restart|force-reload|reload)
95 log_daemon_msg "Restarting $DESC" "$NAME"
97 $DAEMON --invalidate passwd --invalidate group --invalidate hosts
102 0) log_end_msg 0 ; exit 0 ;;
103 1) log_failure_msg " (failed -- old process is still running)." ; exit 1 ;;
104 *) log_failure_msg " (failed to start)." ; exit 1 ;;
108 log_failure_msg " (failed to stop)."
114 log_daemon_msg "Status of $DESC service: "
117 0) log_failure_msg "not running." ; exit 1 ;;
118 1) log_success_msg "running." ; exit 0 ;;
122 echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}" >&2