author | Rich Burridge <rich.burridge@oracle.com> |
Tue, 02 May 2017 17:33:26 -0700 | |
changeset 7964 | d9801318ed3d |
parent 5911 | a8d897c4c442 |
permissions | -rw-r--r-- |
474
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
1 |
#! /usr/bin/ksh93 |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
2 |
|
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
3 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
4 |
# CDDL HEADER START |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
5 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
6 |
# The contents of this file are subject to the terms of the |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
7 |
# Common Development and Distribution License (the "License"). |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
8 |
# You may not use this file except in compliance with the License. |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
9 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
10 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
11 |
# or http://www.opensolaris.org/os/licensing. |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
12 |
# See the License for the specific language governing permissions |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
13 |
# and limitations under the License. |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
14 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
15 |
# When distributing Covered Code, include this CDDL HEADER in each |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
16 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
17 |
# If applicable, add the following below this CDDL HEADER, with the |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
18 |
# fields enclosed by brackets "[]" replaced with your own identifying |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
19 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
20 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
21 |
# CDDL HEADER END |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
22 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
23 |
|
5911
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
24 |
# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
474
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
25 |
# |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
26 |
source /lib/svc/share/smf_include.sh |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
27 |
|
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
28 |
typeset -r LDAPUSR=openldap |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
29 |
typeset -r LDAPGRP=openldap |
1423
27b01995039c
15821768 SUNBT7203918 openldap "make test" should only test distributed backends
doug leavitt <doug.leavitt@oracle.com>
parents:
474
diff
changeset
|
30 |
typeset -r VARRUNDIR=/var/openldap/run |
27b01995039c
15821768 SUNBT7203918 openldap "make test" should only test distributed backends
doug leavitt <doug.leavitt@oracle.com>
parents:
474
diff
changeset
|
31 |
typeset -r VARDATADIR=/var/openldap/openldap-data |
474
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
32 |
typeset -r PIDFILE=${VARRUNDIR}/slapd.pid |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
33 |
typeset -r CONF_FILE=/etc/openldap/slapd.conf |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
34 |
typeset -r SLAPD="/usr/lib/slapd -u ${LDAPUSR} -g ${LDAPGRP} -f ${CONF_FILE}" |
5911
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
35 |
typeset -r CONF_DIR=/etc/openldap/slapd.d |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
36 |
typeset -r SLAPD_DIR="/usr/lib/slapd -u ${LDAPUSR} -g ${LDAPGRP} -F ${CONF_DIR}" |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
37 |
typeset -r LDAPSERVERCFG="/usr/sbin/ldapservercfg" |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
38 |
typeset -r DO_LDAPSERVERCFG="pfexec ${LDAPSERVERCFG} -a openldap" |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
39 |
typeset -r FLAG_STR='olcConfigFile: /tmp/dscfg.' |
474
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
40 |
|
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
41 |
|
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
42 |
case "$1" in |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
43 |
start) |
5911
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
44 |
urls=`/usr/bin/svcprop -c -p config/urls \ |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
45 |
svc:/network/ldap/server:openldap 2>/dev/null` |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
46 |
|
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
47 |
if [[ -x ${LDAPSERVERCFG} ]]; then |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
48 |
grep -q "${FLAG_STR}" ${CONF_DIR}/cn\=config.ldif |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
49 |
[[ $? -eq 0 ]] && exec ${SLAPD_DIR} -h "$urls" 2>&1 |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
50 |
${DO_LDAPSERVERCFG} |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
51 |
else |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
52 |
[[ -f ${CONF_FILE} ]] || exit $SMF_EXIT_ERR_CONFIG |
a8d897c4c442
PSARC/2016/225 OpenLDAP Update to 2.4.44
zihao.zhu@oracle.com <zihao.zhu@oracle.com>
parents:
1423
diff
changeset
|
53 |
exec ${SLAPD} -h "$urls" 2>&1 |
474
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
54 |
fi |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
55 |
;; |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
56 |
stop) |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
57 |
# Use the actual contract, not ${PIDFILE} |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
58 |
smf_kill_contract $2 TERM 1 30 |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
59 |
ret=$? |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
60 |
[ $ret -ne 0 ] && exit 1 |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
61 |
exit $ret |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
62 |
;; |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
63 |
*) |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
64 |
print "Usage: $0 {start|stop}" |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
65 |
exit 1 |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
66 |
;; |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
67 |
esac |
742dc4436b35
7054261 Move OpenLDAP to userland
Srinivasa Sarva <srinivasa.sarva@oracle.com>
parents:
diff
changeset
|
68 |