#!/bin/sh # # nscd: Starts the Name Switch Cache Daemon # # chkconfig: - 30 74 # description: This is a daemon which handles passwd and group lookups \ # for running programs and cache the results for the next \ # query. You should start this daemon if you use \ # slow naming services like NIS, NIS+, LDAP, or hesiod. # processname: /usr/sbin/nscd # config: /etc/nscd.conf # WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions CONFIG=/etc/nscd.conf PIDFILE=/var/run/nscd/nscd.pid LOCKFILE=/var/lock/subsys/nscd RETVAL=0 start() { # Sanity checks. [ -s "$CONFIG" ] || exit # nscd does not run on any kernel lower than 2.2.0 because of threading # problems, so we require that in first place. case "$(uname -r)" in 2.[2-9].*) # this is okay ;; [3-9]*) # these are of course also okay ;; *) # this is not exit 0 ;; esac local secure= for table in passwd group; do if egrep -qs '^'$table':.*nisplus' /etc/nsswitch.conf; then /usr/sbin/nscd_nischeck "$table" || secure="$secure -S $table,yes" fi done start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user nscd -- nscd $secure RETVAL=$? return $RETVAL } stop() { stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user nscd -- nscd RETVAL=$? if [ $RETVAL -eq 0 ]; then # nscd won't be able to remove these when it is running # as a non-privileged user rm -f /var/run/nscd/socket fi return $RETVAL } reload() { msg_reloading nscd stop_daemon --pidfile "$PIDFILE" --expect-user nscd -HUP -- nscd RETVAL=$? return $RETVAL } restart() { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; condreload) if [ -e "$LOCKFILE" ]; then reload fi ;; status) status --pidfile "$PIDFILE" --expect-user nscd -- nscd RETVAL=$? ;; *) msg_usage "${0##*/} {start|stop|status|restart|reload|condstop|condrestart|condreload}" RETVAL=1 ;; esac exit $RETVAL