ogindexd revision e7b21c8124ec55ffacc49c1e28a8685834715484
325N/A#!/sbin/sh
325N/A#
325N/A# CDDL HEADER START
325N/A#
325N/A# The contents of this file are subject to the terms of the
325N/A# Common Development and Distribution License (the "License").
325N/A# You may not use this file except in compliance with the License.
325N/A#
325N/A# See LICENSE.txt included in this distribution for the specific
325N/A# language governing permissions and limitations under the License.
325N/A#
325N/A# When distributing Covered Code, include this CDDL HEADER in each
325N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
325N/A# If applicable, add the following below this CDDL HEADER, with the
325N/A# fields enclosed by brackets "[]" replaced with your own identifying
325N/A# information: Portions Copyright [yyyy] [name of copyright owner]
325N/A#
325N/A# CDDL HEADER END
325N/A#
325N/A# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
325N/A# Use is subject to license terms.
325N/A#
325N/A
325N/APATH="/usr/bin:/bin"
325N/A
325N/Agetprop() {
325N/A svcprop -p opengrok/$1 opengrok | tr -d '\\' | (
325N/A read value
325N/A if [ "x$value" != 'x""' ]; then
325N/A printf "%s" "$value"
325N/A fi
325N/A )
325N/A}
325N/A
325N/Aread_config() {
325N/A SRCDIR=`getprop srcdir`
325N/A
325N/A if [ ! -d "$SRCDIR" ]; then
325N/A echo "FATAL: srcdir $SRCDIR doesn't exist" >&2
325N/A exit $SMF_EXIT_ERR_CONFIG
325N/A fi
325N/A
325N/A JAVA_OPTS="-Xmx`getprop maxmemory`m"
325N/A JAVA_EXTRA_PARAMS=`getprop java_extra_params`
325N/A DATADIR=`getprop cachedir`
325N/A OG_DEF_PARAMS=`getprop default_params`
325N/A OG_EXTRA_PARAMS=`getprop extra_params`
325N/A READONLY_CFG_FILE=`getprop readonly_config`
325N/A READ_XML_CONF=""
325N/A VERBOSE=""
325N/A if [ "`getprop verbose`" != "false" ]; then
325N/A VERBOSE="-v"
325N/A fi
325N/A
325N/A if [ -r "$READONLY_CFG_FILE" ]; then
325N/A READ_XML_CONF="-R $a"
325N/A fi
325N/A}
325N/A
325N/AJAVA=/usr/jdk/latest/bin/java
325N/ALIBDIR=/usr/opengrok/lib
325N/ALOCALSTATEDIR="/var/opengrok"
325N/AWEBAPP_CONFIG_ADDRESS="-U localhost:2424"
325N/AXML_CONFIGURATION="$LOCALSTATEDIR/etc/configuration.xml"
325N/ACLASSPATH=$LIBDIR/opengrok.jar
325N/A
325N/Axx() {
325N/A echo "$@"
325N/A "$@"
325N/A}
325N/A
325N/Arunjava() {
325N/A xx ${JAVA} ${JAVA_OPTS} ${JAVA_EXTRA_PARAMS} \
325N/A -cp ${CLASSPATH} \
325N/A org.opensolaris.opengrok.index.Indexer \
325N/A ${OG_DEF_PARAMS} ${OG_EXTRA_PARAMS} \
325N/A ${READ_XML_CONF} \
325N/A -W ${XML_CONFIGURATION} \
325N/A ${WEBAPP_CONFIG_ADDRESS} \
325N/A ${VERBOSE} \
325N/A -s ${SRCDIR} -d ${DATADIR} "$@"
325N/A}
325N/A
325N/A# Read configuration for the first time.
325N/Aread_config || exit $?
325N/A
325N/Apipe=/var/opengrok/.refresh.pipe
325N/Aif [ ! -p "$pipe" ]; then
325N/A mkfifo "$pipe" || exit 1
325N/Afi
325N/Aif [ ! -f "$XML_CONFIGURATION" ]; then
325N/A # This is likely our first run. Let's do the initial indexing.
325N/A runjava -H || exit 1
325N/Afi
325N/Awhile read line; do
325N/A # Re-read configuration.
325N/A read_config || exit $?
325N/A runjava -H || exit 1
325N/Adone < "$pipe" 5> "$pipe"
325N/A
325N/A