#! /bin/ksh93 # $Id: opendj-method.sh,v 0cfea36e562d 2013-07-16 05:07:31Z jel+forgerock $ # # License: CDDL 1.0 (see http://opensource.org/licenses/cddl-1.0) # Copyright 2013 Jens Elkner . /lib/svc/share/smf_include.sh BASEDIR='@CLIENT_BASEDIR@' typeset -a PROPVAL=( ) function getprop { svcprop -q -p $1 ${SMF_FMRI} if (( $? == 0 )); then typeset X=${ svcprop -p $1 ${SMF_FMRI}; } V LAST='' [[ ${X} == '""' ]] && X="" X=( ${X//\\} ) PROPVAL=( ) integer IN=0 # to allow a double quoted string as arg, we need to parse ourselves for V in ${X[@]} ; do if (( IN )); then if [[ ${V: -1:1} == '"' ]]; then PROPVAL+=( "${LAST} ${V:0:${#V}-1}" ) LAST='' IN=0 else LAST+=" ${V}" fi elif [[ ${V:0:1} == '"' ]]; then V="${V:1}" if [[ ${V: -1:1} == '"' ]]; then PROPVAL+=( "${V:0:${#V}-1}" ) else IN=1 LAST="${V}" fi else PROPVAL+=( "${V}" ) fi done fi } case "$1" in 'start') # per default open files is limited to 256 ulimit -S -n ${ ulimit -H -n ; } getprop config/server_start_args ${BASEDIR}/opendj26/bin/start-ds "${PROPVAL[@]}" RC=$? (( ${RC} == 98 )) && exit ${SMF_EXIT_OK} # Already started (( ${RC} == 999 )) && exit ${SMF_EXIT_ERR_CONFIG} (( ${RC} != 0 )) && exit ${SMF_EXIT_ERR_FATAL} ;; 'stop') getprop config/server_stop_args ${BASEDIR}/opendj26/bin/stop-ds "${PROPVAL[@]}" RC=$? (( ${RC} == 999 )) && exit ${SMF_EXIT_ERR_CONFIG} (( ${RC} != 0 )) && exit ${SMF_EXIT_ERR_FATAL} ;; *) print -u2 "Usage: $0 { start | stop }" exit ${SMF_EXIT_ERR_FATAL} ;; esac exit ${SMF_EXIT_OK}