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