2003-12-31 21:44:08 +00:00
|
|
|
#!/bin/bash
|
1998-01-31 08:39:55 +00:00
|
|
|
#
|
|
|
|
# nscd: Starts the Name Switch Cache Daemon
|
|
|
|
#
|
2003-12-31 21:44:08 +00:00
|
|
|
# chkconfig: - 30 74
|
1998-08-31 11:11:15 +00:00
|
|
|
# description: This is a daemon which handles passwd and group lookups \
|
|
|
|
# for running programs and cache the results for the next \
|
2003-12-31 21:44:08 +00:00
|
|
|
# query. You should start this daemon if you use \
|
|
|
|
# slow naming services like NIS, NIS+, LDAP, or hesiod.
|
|
|
|
# processname: /usr/sbin/nscd
|
1998-08-31 11:11:15 +00:00
|
|
|
# config: /etc/nscd.conf
|
|
|
|
#
|
2005-06-20 15:49:08 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: nscd
|
|
|
|
# Required-Start: $syslog
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Starts the Name Switch Cache Daemon
|
|
|
|
# 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.
|
|
|
|
### END INIT INFO
|
1998-08-31 11:11:15 +00:00
|
|
|
|
|
|
|
# Sanity checks.
|
|
|
|
[ -f /etc/nscd.conf ] || exit 0
|
|
|
|
[ -x /usr/sbin/nscd ] || exit 0
|
1998-01-31 08:39:55 +00:00
|
|
|
|
|
|
|
# Source function library.
|
2003-12-31 21:44:08 +00:00
|
|
|
. /etc/init.d/functions
|
1998-01-31 08:39:55 +00:00
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
# 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
|
2005-06-20 15:49:08 +00:00
|
|
|
exit 1
|
2004-12-22 20:10:10 +00:00
|
|
|
;;
|
|
|
|
esac
|
1999-08-17 01:37:38 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
2003-12-31 21:44:08 +00:00
|
|
|
prog=nscd
|
|
|
|
|
|
|
|
start () {
|
|
|
|
[ -d /var/run/nscd ] || mkdir /var/run/nscd
|
2004-10-15 21:20:11 +00:00
|
|
|
[ -d /var/db/nscd ] || mkdir /var/db/nscd
|
2003-12-31 21:44:08 +00:00
|
|
|
secure=""
|
|
|
|
# for table in passwd group hosts
|
|
|
|
# do
|
|
|
|
# if egrep -q '^'$table':.*nisplus' /etc/nsswitch.conf; then
|
|
|
|
# /usr/lib/nscd_nischeck $table || secure="$secure -S $table,yes"
|
|
|
|
# fi
|
|
|
|
# done
|
|
|
|
echo -n $"Starting $prog: "
|
2004-12-22 20:10:10 +00:00
|
|
|
daemon /usr/sbin/nscd $secure
|
2003-12-31 21:44:08 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop () {
|
|
|
|
echo -n $"Stopping $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/nscd.pid
|
2004-09-13 17:24:41 +00:00
|
|
|
rm -f /var/run/nscd/socket
|
2003-12-31 21:44:08 +00:00
|
|
|
success $"$prog shutdown"
|
|
|
|
else
|
|
|
|
failure $"$prog shutdown"
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
1999-08-17 01:37:38 +00:00
|
|
|
|
1998-01-31 08:39:55 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2003-12-31 21:44:08 +00:00
|
|
|
start
|
1999-08-17 01:37:38 +00:00
|
|
|
RETVAL=$?
|
1998-01-31 08:39:55 +00:00
|
|
|
;;
|
|
|
|
stop)
|
2003-12-31 21:44:08 +00:00
|
|
|
stop
|
1999-08-17 01:37:38 +00:00
|
|
|
RETVAL=$?
|
1998-01-31 08:39:55 +00:00
|
|
|
;;
|
2003-12-31 21:44:08 +00:00
|
|
|
status)
|
2005-02-07 19:30:19 +00:00
|
|
|
status nscd
|
1999-08-17 01:37:38 +00:00
|
|
|
RETVAL=$?
|
2005-02-07 19:30:19 +00:00
|
|
|
;;
|
2003-12-31 21:44:08 +00:00
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2005-06-20 15:49:08 +00:00
|
|
|
try-restart | condrestart)
|
2003-12-31 21:44:08 +00:00
|
|
|
[ -e /var/lock/subsys/nscd ] && restart
|
1999-08-17 01:37:38 +00:00
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2005-06-20 15:49:08 +00:00
|
|
|
force-reload | reload)
|
2005-02-07 19:30:19 +00:00
|
|
|
echo -n $"Reloading $prog: "
|
|
|
|
killproc /usr/sbin/nscd -HUP
|
1999-08-17 01:37:38 +00:00
|
|
|
RETVAL=$?
|
2005-02-07 19:30:19 +00:00
|
|
|
echo
|
|
|
|
;;
|
1998-01-31 08:39:55 +00:00
|
|
|
*)
|
2003-12-31 21:44:08 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
|
|
|
RETVAL=1
|
1998-01-31 08:39:55 +00:00
|
|
|
;;
|
|
|
|
esac
|
1999-08-17 01:37:38 +00:00
|
|
|
exit $RETVAL
|