]>
Commit | Line | Data |
---|---|---|
205302ea AF |
1 | #!/bin/sh |
2 | # | |
5ea9ee19 | 3 | # ldap Startup script for the OpenLDAP server |
205302ea | 4 | # |
9694cccc | 5 | # chkconfig: 345 20 80 |
205302ea | 6 | # |
5ea9ee19 | 7 | # description: OpenLDAP is a Lightweight Directory Access Protocol server |
205302ea | 8 | # |
5ea9ee19 | 9 | # processname: slapd |
c29db80e | 10 | # pidfile: /var/run/slapd/slapd.pid |
205302ea | 11 | |
5ea9ee19 | 12 | |
13 | # Source function library | |
205302ea AF |
14 | . /etc/rc.d/init.d/functions |
15 | ||
5ea9ee19 | 16 | # Get network config |
205302ea AF |
17 | . /etc/sysconfig/network |
18 | ||
76760080 JB |
19 | # defaults |
20 | SLAPDSYSLOGLEVEL="" | |
21 | SLAPDURLLIST="" | |
22 | SLAPDOPTIONS="" | |
5dbb548b ER |
23 | SLAPD_SOCKET_PATH=/var/run/ldapi |
24 | SLAPD_CONFIG_FILE=/etc/openldap/slapd.conf | |
25 | ||
26 | # setup instance variable, can be used to sysconfig/ldap to do some magic | |
27 | SLAPD_INSTANCE=${0##*/} | |
ea598084 | 28 | SLAPD_INSTANCE=${SLAPD_INSTANCE##[SK][0-9][0-9]} |
76760080 | 29 | |
5ea9ee19 | 30 | # Get service config |
205302ea AF |
31 | [ -f /etc/sysconfig/ldap ] && . /etc/sysconfig/ldap |
32 | ||
33 | # Check that networking is up. | |
cf553e11 | 34 | if is_yes "${NETWORKING}"; then |
7dff7e14 | 35 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
cf553e11 | 36 | msg_network_down OpenLDAP |
37 | exit 1 | |
38 | fi | |
39 | else | |
40 | exit 0 | |
912b6ac2 | 41 | fi |
98baf214 | 42 | |
5dbb548b ER |
43 | lockfile=/var/lock/subsys/$SLAPD_INSTANCE |
44 | pidfile=$(awk '/^pidfile/ {print $2}' $SLAPD_CONFIG_FILE) | |
45 | pidfile=${pidfile:-/var/run/slapd/slapd.pid} | |
46 | ||
2d3ff001 | 47 | start() { |
5dbb548b | 48 | if [ -f $lockfile ]; then |
ec76751d | 49 | msg_already_running "OpenLDAP" |
39e59323 ER |
50 | return |
51 | fi | |
52 | ||
53 | msg_starting "OpenLDAP" | |
54 | ARGS="-u slapd -g slapd" | |
55 | if [ -n "$SLAPDSYSLOGLEVEL" ]; then | |
56 | ARGS="$ARGS -s $SLAPDSYSLOGLEVEL" | |
57 | fi | |
58 | if [ -n "$SLAPDOPTIONS" ]; then | |
59 | ARGS="$ARGS $SLAPDOPTIONS" | |
60 | fi | |
61 | # optionally support old option | |
62 | if [ -n "$SLAPDNICE" ]; then | |
63 | SERVICE_RUN_NICE_LEVEL=$SLAPDNICE | |
64 | fi | |
7e5b7595 | 65 | |
5dbb548b ER |
66 | if [ -n "$SLAPD_CONFIG_FILE" ]; then |
67 | ARGS="$ARGS -f $SLAPD_CONFIG_FILE" | |
68 | fi | |
69 | ||
7e5b7595 ER |
70 | if is_yes $RC_LOGGING; then |
71 | daemon /usr/sbin/slapd $ARGS ${SLAPDURLLIST:+ -h \"$SLAPDURLLIST\"} | |
72 | else | |
73 | daemon /usr/sbin/slapd $ARGS ${SLAPDURLLIST:+ -h "$SLAPDURLLIST"} | |
74 | fi | |
75 | ||
39e59323 | 76 | RETVAL=$? |
5dbb548b ER |
77 | [ $RETVAL -eq 0 ] && touch $lockfile |
78 | if [ $RETVAL -eq 0 -a -S $SLAPD_SOCKET_PATH ]; then | |
79 | chown "$LDAPI_SOCKET_OWNER":"$LDAPI_SOCKET_GROUP" $SLAPD_SOCKET_PATH && \ | |
80 | chmod "$LDAPI_SOCKET_MODE" $SLAPD_SOCKET_PATH | |
205302ea | 81 | fi |
2d3ff001 JB |
82 | } |
83 | ||
84 | stop() { | |
5dbb548b | 85 | if [ ! -f $lockfile ]; then |
cf553e11 | 86 | msg_not_running "OpenLDAP" |
39e59323 | 87 | return |
587991d4 | 88 | fi |
39e59323 ER |
89 | |
90 | msg_stopping "OpenLDAP" | |
fef48147 | 91 | killproc --pidfile $pidfile --waitforname slapd --waitfortime 300 slapd |
5dbb548b | 92 | rm -f $lockfile >/dev/null 2>&1 |
2d3ff001 JB |
93 | } |
94 | ||
95 | condrestart() { | |
5dbb548b | 96 | if [ -f $lockfile ]; then |
2d3ff001 JB |
97 | stop |
98 | start | |
99 | else | |
100 | msg_not_running "OpenLDAP" | |
101 | RETVAL=$1 | |
102 | fi | |
103 | } | |
104 | ||
105 | RETVAL=0 | |
106 | # See how we were called. | |
107 | case "$1" in | |
108 | start) | |
109 | start | |
110 | ;; | |
111 | stop) | |
112 | stop | |
113 | ;; | |
114 | restart) | |
115 | stop | |
116 | start | |
117 | ;; | |
118 | try-restart) | |
119 | condrestart 0 | |
120 | ;; | |
121 | force-reload) | |
122 | condrestart 7 | |
205302ea AF |
123 | ;; |
124 | status) | |
5dbb548b | 125 | status --pidfile $pidfile slapd |
7fc4deca | 126 | RETVAL=$? |
205302ea | 127 | ;; |
205302ea | 128 | *) |
2d3ff001 | 129 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
7fc4deca | 130 | exit 3 |
205302ea AF |
131 | esac |
132 | ||
587991d4 | 133 | exit $RETVAL |