#!/bin/ksh93
# $Id: setup 554 2013-04-22 09:12:58Z elkner $
#
# License: CDDL 1.0 (see http://opensource.org/licenses/cddl-1.0)
# Copyright 2013 Jens Elkner
[[ ${FNTRACE} == 'ALL' || ${FNTRACE} == 'main' ]] && set -x
INSTALL_ROOT="${.sh.file%/*}" SCRIPT_NAME='setup'
# Set env vars
. "${INSTALL_ROOT}"/lib/_script-util.sh
checkEnv 'set-full-environment-and-test-java'
integer INFO=0
isVersionOrHelp "$@" && INFO=1
# If running as ldapd it is assumed, that the target is a system instance
if (( ! INFO )) && [[ ${ uname -s ; } == 'SunOs' && ${ id -un ; } == 'ldapd' ]]
then
X=${ svcs -H -o state ${SMF_FMRI} 2>/dev/null ; }
if [[ -z $X ]]; then
print -u2 'The system does not know anything about the service' \
"'${SMF_FMRI}'"
exit 1
fi
if [[ $X != 'disabled' ]]; then
# The script runs as the instance owner (default: ldapd), which should
# not have solaris.smf.manage.opendj authorization. So trying to
# disable it would yield an error anyway.
#print -u2 "Trying to disable service '${SMF_FMRI}' ..."
#/usr/sbin/svcadm disable -s "${SMF_FMRI}" || exit 1
#print -u2 "Done."
print -u2 "Service '${SMF_FMRI}' is not disabled." '
Use the following command to disable it before starting setup again:
\t' "svcadm disable ${SMF_FMRI}"
exit 1
fi
fi
RM_FILES="keystore.pin truststore keystore"
EXISTING_FILES=' '
for F in ${RM_FILES} ; do
[[ -f ${INSTANCE_ROOT}/config/$F ]] && EXISTING_FILES+="${F} "
done
# Launch the setup
# MaintainConfigArchive is needed, otherwise if the cli gets invoked, it writes
# an archived config unconditionally _on startup_, which would prevent runnning
# setup again, even if it did not succeed/was aborted in a previous run.
"${OPENDJ_JAVA_BIN}" ${OPENDJ_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
-Dorg.opends.server.InstallRoot="${INSTALL_ROOT}" \
-Dorg.opends.server.InstanceRoot="${INSTANCE_ROOT}" \
-Dorg.opends.server.MaintainConfigArchive=false \
org.opends.quicksetup.installer.SetupLauncher "$@"
RC=$?
(( ${INFO} )) && exit ${RC}
if (( ${RC} != 50 )); then
# remove the files, which would people driving nuts, because a 2nd run
# of setup would re-use them ...
for F in ${RM_FILES} ; do
FILE="${INSTANCE_ROOT}/config/$F"
[[ ! -f ${FILE} ]] && continue
[[ ${EXISTING_FILES// $F /} == ${EXISTING_FILES} ]] && rm -f "${FILE}"
done
exit ${RC}
fi
exit 0