1#!/bin/bash 2# 3# nscd: Starts the Name Switch Cache Daemon 4# 5# chkconfig: - 30 74 6# description: This is a daemon which handles passwd and group lookups \ 7# for running programs and cache the results for the next \ 8# query. You should start this daemon if you use \ 9# slow naming services like NIS, NIS+, LDAP, or hesiod. 10# processname: /usr/sbin/nscd 11# config: /etc/nscd.conf 12# 13### BEGIN INIT INFO 14# Provides: nscd 15# Required-Start: $syslog 16# Default-Stop: 0 1 6 17# Short-Description: Starts the Name Switch Cache Daemon 18# Description: This is a daemon which handles passwd and group lookups \ 19# for running programs and cache the results for the next \ 20# query. You should start this daemon if you use \ 21# slow naming services like NIS, NIS+, LDAP, or hesiod. 22### END INIT INFO 23 24# Sanity checks. 25[ -f /etc/nscd.conf ] || exit 0 26[ -x /usr/sbin/nscd ] || exit 0 27 28# Source function library. 29. /etc/init.d/functions 30 31# nscd does not run on any kernel lower than 2.2.0 because of threading 32# problems, so we require that in first place. 33case $(uname -r) in 34 2.[2-9].*) 35 # this is okay 36 ;; 37 [3-9]*) 38 # these are of course also okay 39 ;; 40 *) 41 #this is not 42 exit 1 43 ;; 44esac 45 46RETVAL=0 47prog=nscd 48 49start () { 50 [ -d /var/run/nscd ] || mkdir /var/run/nscd 51 [ -d /var/db/nscd ] || mkdir /var/db/nscd 52 echo -n $"Starting $prog: " 53 daemon /usr/sbin/nscd 54 RETVAL=$? 55 echo 56 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd 57 return $RETVAL 58} 59 60stop () { 61 echo -n $"Stopping $prog: " 62 /usr/sbin/nscd -K 63 RETVAL=$? 64 if [ $RETVAL -eq 0 ]; then 65 rm -f /var/lock/subsys/nscd 66 # nscd won't be able to remove these if it is running as 67 # a non-privileged user 68 rm -f /var/run/nscd/nscd.pid 69 rm -f /var/run/nscd/socket 70 success $"$prog shutdown" 71 else 72 failure $"$prog shutdown" 73 fi 74 echo 75 return $RETVAL 76} 77 78restart() { 79 stop 80 start 81} 82 83# See how we were called. 84case "$1" in 85 start) 86 start 87 RETVAL=$? 88 ;; 89 stop) 90 stop 91 RETVAL=$? 92 ;; 93 status) 94 status nscd 95 RETVAL=$? 96 ;; 97 restart) 98 restart 99 RETVAL=$? 100 ;; 101 try-restart | condrestart) 102 [ -e /var/lock/subsys/nscd ] && restart 103 RETVAL=$? 104 ;; 105 force-reload | reload) 106 echo -n $"Reloading $prog: " 107 killproc /usr/sbin/nscd -HUP 108 RETVAL=$? 109 echo 110 ;; 111 *) 112 echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" 113 RETVAL=1 114 ;; 115esac 116exit $RETVAL 117