blob: 9aa61e4b1abdd5243ed0e171ea8c37339f8e4bff (
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/bin/sh
#
# ldap Startup script for the OpenLDAP server
#
# chkconfig: 345 20 80
#
# description: OpenLDAP is a Lightweight Directory Access Protocol server
#
# processname: slapd
# pidfile: /var/run/slapd/slapd.pid
# Source function library
. /etc/rc.d/init.d/functions
# Get network config
. /etc/sysconfig/network
# defaults
SLAPDSYSLOGLEVEL=""
SLAPDURLLIST=""
SLAPDOPTIONS=""
SLAPD_SOCKET_PATH=/var/run/ldapi
SLAPD_CONFIG_FILE=/etc/openldap/slapd.conf
# setup instance variable, can be used to sysconfig/ldap to do some magic
SLAPD_INSTANCE=${0##*/}
SLAPD_INSTANCE=${SLAPD_INSTANCE##[SK][0-9][0-9]}
# Get service config
[ -f /etc/sysconfig/ldap ] && . /etc/sysconfig/ldap
# Check that networking is up.
if is_yes "${NETWORKING}"; then
if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
msg_network_down OpenLDAP
exit 1
fi
else
exit 0
fi
lockfile=/var/lock/subsys/$SLAPD_INSTANCE
pidfile=$(awk '/^pidfile/ {print $2}' $SLAPD_CONFIG_FILE)
pidfile=${pidfile:-/var/run/slapd/slapd.pid}
start() {
if [ -f $lockfile ]; then
msg_already_running "OpenLDAP"
return
fi
msg_starting "OpenLDAP"
ARGS="-u slapd -g slapd"
if [ -n "$SLAPDSYSLOGLEVEL" ]; then
ARGS="$ARGS -s $SLAPDSYSLOGLEVEL"
fi
if [ -n "$SLAPDOPTIONS" ]; then
ARGS="$ARGS $SLAPDOPTIONS"
fi
# optionally support old option
if [ -n "$SLAPDNICE" ]; then
SERVICE_RUN_NICE_LEVEL=$SLAPDNICE
fi
if [ -n "$SLAPD_CONFIG_FILE" ]; then
ARGS="$ARGS -f $SLAPD_CONFIG_FILE"
fi
if is_yes $RC_LOGGING; then
daemon /usr/sbin/slapd $ARGS ${SLAPDURLLIST:+ -h \"$SLAPDURLLIST\"}
else
daemon /usr/sbin/slapd $ARGS ${SLAPDURLLIST:+ -h "$SLAPDURLLIST"}
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
if [ $RETVAL -eq 0 -a -S $SLAPD_SOCKET_PATH ]; then
chown "$LDAPI_SOCKET_OWNER":"$LDAPI_SOCKET_GROUP" $SLAPD_SOCKET_PATH && \
chmod "$LDAPI_SOCKET_MODE" $SLAPD_SOCKET_PATH
fi
}
stop() {
if [ ! -f $lockfile ]; then
msg_not_running "OpenLDAP"
return
fi
msg_stopping "OpenLDAP"
killproc --pidfile $pidfile --waitforname slapd --waitfortime 300 slapd
rm -f $lockfile >/dev/null 2>&1
}
condrestart() {
if [ -f $lockfile ]; then
stop
start
else
msg_not_running "OpenLDAP"
RETVAL=$1
fi
}
RETVAL=0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
try-restart)
condrestart 0
;;
force-reload)
condrestart 7
;;
status)
status --pidfile $pidfile slapd
RETVAL=$?
;;
*)
msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
exit 3
esac
exit $RETVAL
|