96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#! /bin/sh
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# CDDL HEADER START
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# The contents of this file are subject to the terms of the
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# Common Development and Distribution License (the "License").
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# You may not use this file except in compliance with the License.
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# See LICENSE.txt included in this distribution for the specific
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# language governing permissions and limitations under the License.
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# When distributing Covered Code, include this CDDL HEADER in each
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# file and include the License file at LICENSE.txt.
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# If applicable, add the following below this CDDL HEADER, with the
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# fields enclosed by brackets "[]" replaced with your own identifying
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# information: Portions Copyright [yyyy] [name of copyright owner]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# CDDL HEADER END
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye#
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye# Use is subject to license terms.
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyecd ${ROOT}
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyeif [ ! -f ${ROOT}/smf/next ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyethen
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye echo 1 > smf/next
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyefi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyeread stage < smf/next
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyeoutput=/tmp/opengrok.$$
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyesend_report()
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye{
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye if [ -n "${ADMINISTRATOR}" ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye mailx -s "{OpenGrok update failed" ${ADMINISTRATOR} < ${output}
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye}
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond NorbyePROGDIR=${ROOT}/bin
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyeexport PROGDIR
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyewhile true
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyedo
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye SRC_ROOT=${ROOT}/stage${stage}/source; export SRC_ROOT
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye DATA_ROOT=${ROOT}/stage${stage}/data; export DATA_ROOT
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # update source code
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye rm -f ${output}
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye ./smf/update_source.sh > ${output} 2>&1
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye if [ $? -ne 0 ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye send_report
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye else
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # (re)generate index database
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye echo "Update index database" >> ${output}
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye # You may want to add something like the following command
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye # to automatically generate projects for each subdirectory in the
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye # SRC_ROOT directory. The -p options let you specify the project
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye # that should be selected by default (note that the parameter here
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye # is the path to the project)
2e3888b9e322264fa8a5bd5c8b52df231f2eededTrond Norbye # ADD_PROJECTS="-S -P -p /onnv-gate -W ${DATA_ROOT}/../configuration.xml"
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye ${JAVA_HOME}/bin/java -Xmx1524m -jar ${PROGDIR}/opengrok.jar \
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye -H -R ${DATA_ROOT}/../configuration.xml \
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye ${ADD_PROJECTS} >> ${output} 2>&1
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye if [ $? -ne 0 ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye send_report
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye else
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye rm -f configuration.xml
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye ln -s stage${stage}/configuration.xml
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # notify web-servers
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye if [ -n "$WEBSERVERS" ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye for f in $WEBSERVERS
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye do
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # Use rsync to populate the files out to the web server
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # rsync -a configuration.xml stage${stage} \
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # /net/`echo $f|cut -f1 -d:`/opengrok/
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # if [ $? -eq 0 ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # Tell the web server to use the new configuration
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye ${JAVA_HOME}/bin/java -Xmx1524m \
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye -jar ${PROGDIR}/opengrok.jar \
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye -U ${f} \
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye -R ${DATA_ROOT}/../configuration.xml \
66d6362ed4101c93b6eaa749598bfb3cd030be3fTrond Norbye -n >> ${output} 2>&1
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye done
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye # update running configuration
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye if [ "${stage}" = 1 ]
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye then
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye stage=2
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye else
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye stage=1
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye echo ${stage} > smf/next
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye fi
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbye sleep ${SLEEPTIME}
96c1ae30d032621b47c4ac375b151ddaef5f1507Trond Norbyedone