components/openldap/Solaris/ldap-olslapd
changeset 5911 a8d897c4c442
parent 1423 27b01995039c
equal deleted inserted replaced
5910:93ac80235738 5911:a8d897c4c442
    19 # information: Portions Copyright [yyyy] [name of copyright owner]
    19 # information: Portions Copyright [yyyy] [name of copyright owner]
    20 #
    20 #
    21 # CDDL HEADER END
    21 # CDDL HEADER END
    22 #
    22 #
    23 
    23 
    24 # Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    24 # Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
    25 #
    25 #
    26 source /lib/svc/share/smf_include.sh
    26 source /lib/svc/share/smf_include.sh
    27 
    27 
    28 typeset -r LDAPUSR=openldap
    28 typeset -r LDAPUSR=openldap
    29 typeset -r LDAPGRP=openldap
    29 typeset -r LDAPGRP=openldap
    30 typeset -r VARRUNDIR=/var/openldap/run
    30 typeset -r VARRUNDIR=/var/openldap/run
    31 typeset -r VARDATADIR=/var/openldap/openldap-data
    31 typeset -r VARDATADIR=/var/openldap/openldap-data
    32 typeset -r PIDFILE=${VARRUNDIR}/slapd.pid
    32 typeset -r PIDFILE=${VARRUNDIR}/slapd.pid
    33 typeset -r CONF_FILE=/etc/openldap/slapd.conf
    33 typeset -r CONF_FILE=/etc/openldap/slapd.conf
    34 typeset -r SLAPD="/usr/lib/slapd -u ${LDAPUSR} -g ${LDAPGRP} -f ${CONF_FILE}"
    34 typeset -r SLAPD="/usr/lib/slapd -u ${LDAPUSR} -g ${LDAPGRP} -f ${CONF_FILE}"
    35 
    35 typeset -r CONF_DIR=/etc/openldap/slapd.d
    36 [[ ! -f ${CONF_FILE} ]] && exit $SMF_EXIT_ERR_CONFIG
    36 typeset -r SLAPD_DIR="/usr/lib/slapd -u ${LDAPUSR} -g ${LDAPGRP} -F ${CONF_DIR}"
       
    37 typeset -r LDAPSERVERCFG="/usr/sbin/ldapservercfg"
       
    38 typeset -r DO_LDAPSERVERCFG="pfexec ${LDAPSERVERCFG} -a openldap"
       
    39 typeset -r FLAG_STR='olcConfigFile: /tmp/dscfg.'
    37 
    40 
    38 
    41 
    39 case "$1" in
    42 case "$1" in
    40 start)
    43 start)
    41         if [[ ! -d ${VARRUNDIR} ]] ; then
    44 	urls=`/usr/bin/svcprop -c -p config/urls \
    42 		/usr/bin/mkdir -m 700 ${VARRUNDIR} || exit $SMF_EXIT_ERR_CONFIG
    45 	    svc:/network/ldap/server:openldap 2>/dev/null`
    43 		/usr/bin/chown ${LDAPUSR}:${LDAPGRP} ${VARRUNDIR}
    46 
    44         else
    47 	if [[ -x ${LDAPSERVERCFG} ]]; then
    45 		/bin/rm -f ${PIDFILE}
    48 		grep -q "${FLAG_STR}" ${CONF_DIR}/cn\=config.ldif
       
    49 		[[ $? -eq 0 ]] && exec ${SLAPD_DIR} -h "$urls" 2>&1
       
    50 		${DO_LDAPSERVERCFG}
       
    51 	else
       
    52 		[[ -f ${CONF_FILE} ]] || exit $SMF_EXIT_ERR_CONFIG
       
    53 		exec ${SLAPD} -h "$urls" 2>&1
    46 	fi
    54 	fi
    47 
       
    48 	cd ${VARDATADIR}
       
    49 	/usr/bin/db_recover >/dev/null 2>&1
       
    50         exec ${SLAPD} 2>&1
       
    51         ;;
    55         ;;
    52 stop)
    56 stop)
    53 	# Use the actual contract, not ${PIDFILE}
    57 	# Use the actual contract, not ${PIDFILE}
    54 	smf_kill_contract $2 TERM 1 30
    58 	smf_kill_contract $2 TERM 1 30
    55         ret=$?
    59         ret=$?
    60         print "Usage: $0 {start|stop}"
    64         print "Usage: $0 {start|stop}"
    61         exit 1
    65         exit 1
    62         ;;
    66         ;;
    63 esac
    67 esac
    64 
    68 
    65 # not reached