2003-12-31 22:44:08 +01:00
|
|
|
#!/bin/bash
|
1998-01-31 09:39:55 +01:00
|
|
|
#
|
|
|
|
# nscd: Starts the Name Switch Cache Daemon
|
|
|
|
#
|
2003-12-31 22:44:08 +01:00
|
|
|
# chkconfig: - 30 74
|
1998-08-31 13:11:15 +02: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 22:44:08 +01: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 13:11:15 +02:00
|
|
|
# config: /etc/nscd.conf
|
|
|
|
#
|
|
|
|
|
|
|
|
# Sanity checks.
|
|
|
|
[ -f /etc/nscd.conf ] || exit 0
|
|
|
|
[ -x /usr/sbin/nscd ] || exit 0
|
1998-01-31 09:39:55 +01:00
|
|
|
|
|
|
|
# Source function library.
|
2003-12-31 22:44:08 +01:00
|
|
|
. /etc/init.d/functions
|
1998-01-31 09:39:55 +01:00
|
|
|
|
1999-08-17 03:37:38 +02: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
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
RETVAL=0
|
2003-12-31 22:44:08 +01:00
|
|
|
prog=nscd
|
|
|
|
|
|
|
|
start () {
|
|
|
|
[ -d /var/run/nscd ] || mkdir /var/run/nscd
|
2004-10-15 23:20:11 +02:00
|
|
|
[ -d /var/db/nscd ] || mkdir /var/db/nscd
|
2003-12-31 22:44:08 +01: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: "
|
|
|
|
daemon /usr/sbin/nscd $secure
|
|
|
|
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 19:24:41 +02:00
|
|
|
rm -f /var/run/nscd/socket
|
2003-12-31 22:44:08 +01:00
|
|
|
success $"$prog shutdown"
|
|
|
|
else
|
|
|
|
failure $"$prog shutdown"
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
1999-08-17 03:37:38 +02:00
|
|
|
|
1998-01-31 09:39:55 +01:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2003-12-31 22:44:08 +01:00
|
|
|
start
|
1999-08-17 03:37:38 +02:00
|
|
|
RETVAL=$?
|
1998-01-31 09:39:55 +01:00
|
|
|
;;
|
|
|
|
stop)
|
2003-12-31 22:44:08 +01:00
|
|
|
stop
|
1999-08-17 03:37:38 +02:00
|
|
|
RETVAL=$?
|
1998-01-31 09:39:55 +01:00
|
|
|
;;
|
2003-12-31 22:44:08 +01:00
|
|
|
status)
|
1998-01-31 09:39:55 +01:00
|
|
|
status nscd
|
1999-08-17 03:37:38 +02:00
|
|
|
RETVAL=$?
|
1998-01-31 09:39:55 +01:00
|
|
|
;;
|
2003-12-31 22:44:08 +01:00
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
[ -e /var/lock/subsys/nscd ] && restart
|
1999-08-17 03:37:38 +02:00
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2003-12-31 22:44:08 +01:00
|
|
|
reload)
|
|
|
|
killproc /usr/sbin/nscd -HUP
|
1999-08-17 03:37:38 +02:00
|
|
|
RETVAL=$?
|
1998-01-31 09:39:55 +01:00
|
|
|
;;
|
|
|
|
*)
|
2003-12-31 22:44:08 +01:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
|
|
|
RETVAL=1
|
1998-01-31 09:39:55 +01:00
|
|
|
;;
|
|
|
|
esac
|
1999-08-17 03:37:38 +02:00
|
|
|
exit $RETVAL
|