summaryrefslogtreecommitdiff
path: root/nscd/nscd.init
blob: cf2461b9c7702b4cd24dc4beb954a61bd1b53744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# 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
# config: /etc/sysconfig/nscd
#
### 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

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

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

# Source an auxiliary options file if we have one, and pick up NSCD_OPTIONS.
[ -r /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd

RETVAL=0
prog=nscd

start () {
    [ -d /var/run/nscd ] || mkdir /var/run/nscd
    [ -d /var/db/nscd ] || mkdir /var/db/nscd
    echo -n $"Starting $prog: "
    daemon /usr/sbin/nscd $NSCD_OPTIONS
    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
	rm -f /var/run/nscd/socket
       	success $"$prog shutdown"
    else
       	failure $"$prog shutdown"
    fi
    echo
    return $RETVAL
}

restart() {
    stop
    start
}

# See how we were called.
case "$1" in
    start)
	[ -e /var/lock/subsys/nscd ] || start
	RETVAL=$?
	;;
    stop)
	[ ! -e /var/lock/subsys/nscd ] || stop
	RETVAL=$?
	;;
    status)
	status nscd
	RETVAL=$?
	;;
    restart)
	restart
	RETVAL=$?
	;;
    try-restart | condrestart)
	[ ! -e /var/lock/subsys/nscd ] || restart
	RETVAL=$?
	;;
    force-reload | reload)
    	echo -n $"Reloading $prog: "
    	RETVAL=0
    	/usr/sbin/nscd -i passwd || RETVAL=$?
    	/usr/sbin/nscd -i group || RETVAL=$?
    	/usr/sbin/nscd -i hosts || RETVAL=$?
    	/usr/sbin/nscd -i services || RETVAL=$?
    	echo
	;;
    *)
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
	RETVAL=1
	;;
esac
exit $RETVAL