Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 14b4e0d04f00bd666a4e3360d60bf94e > files > 2

nscd-2.3.3-12.8.100mdk.i586.rpm

#!/bin/bash
#
# nscd:		Starts the Name Switch Cache Daemon
#
# chkconfig: 345 30 80
# 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
#

# Sanity checks.
[ -f /etc/nscd.conf ] || exit 0
[ -x /usr/sbin/nscd ] || exit 0

# Source function library.
. /etc/rc.d/init.d/functions

# 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

RETVAL=0
prog=nscd

function start() {
	secure=""
#	for table in passwd group
#	do
#		if egrep '^'$table':.*nisplus' /etc/nsswitch.conf >/dev/null
#		then
#			/usr/lib/nscd_nischeck $table ||
#				secure="$secure -S $table,yes"
#		fi
#	done
	gprintf "Starting %s: " "$prog"
	daemon /usr/sbin/nscd $secure
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
	return $RETVAL
}

function stop() {
	gprintf "Stopping %s: " "$prog"
	/usr/sbin/nscd -K
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		rm -f /var/lock/subsys/nscd
        # nscd won't be able to remove these if it is running as
        # a non-privileged user
		rm -f /var/run/nscd.pid
		rm -f /var/run/.nscd_socket
		success "%s shutdown" "$prog"
	else
		failure "%s shutdown" "$prog"
	fi
	echo
	return $RETVAL
}

function restart() {
	stop
	start
}

# See how we were called.
case "$1" in
    start)
		start
		RETVAL=$?
		;;
    stop)
		stop
		RETVAL=$?
		;;
	status)
        status nscd
		RETVAL=$?
		;;
	restart)
		restart
		RETVAL=$?
		;;
	condrestart)
		[[ -e /var/lock/subsys/nscd ]] && restart
		RETVAL=$?
		;;
	reload)
		killproc /usr/sbin/nscd -HUP
		RETVAL=$?
        ;;
    *)
		gprintf "Usage: %s {start|stop|status|restart|condrestart|reload}\n" "$0"
		RETVAL=1
		;;
esac
exit $RETVAL