#!/bin/bash # install.sh [target folder] SOLR_VERSION=4.5.1 JETTY_VERSION=8.1.14.v20131031 JETTY_PATH=jetty-distribution-$JETTY_VERSION # TODO: prompt for install location export ROOT=./install QUIET=0 ARGS=$() set -- $(getopt -u -o h:p:P:l:c:q -n "install.sh" -- $@) while true; do case "$1" in -h) HOST=$2; shift 2 ;; -p) PORT=$2 shift 2;; -P) PASS=$2 shift 2;; -l) LOGIN=$2 shift 2;; -c) CHARSET=$2 shift 2;; -q) QUIET=1 shift;; --) shift; break;; esac done #echo "HOST = $HOST" #echo "PORT = $PORT" #echo "PASS = $PASS" #echo "LOGIN = $LOGIN" #echo "CHARSET = $CHARSET" # get the perforce server address, login, etc. for the config file if [[ ! -n "${HOST}" ]]; then read -p "Enter the Perforce Server hostname: " HOST fi if [[ ! -n "${PORT}" ]]; then read -p "Enter the Perforce Server port: " PORT fi if [[ ! -n "${CHARSET}" ]]; then read -p "Enter the Perforce Server charset (leave empty for non-unicde servers): " CHARSET fi if [[ ! -n "${LOGIN}" ]]; then read -p "Enter the Perforce Server login: " LOGIN fi if [[ ! -n "${PASS}" ]]; then read -p "Enter the Perforce Server password: " -s PASS echo fi echo export P4CHARSET=$CHARSET # test the settings # if you do not have "p4" in the path you get a non-fatal error message RESULT=$(echo $PASS | p4 -p$HOST:$PORT -u$LOGIN login) RETVAL=$? echo $RESULT if [[ ${QUIET} == 0 && "$RETVAL" != 0 ]] ; then read -p "ERROR: Failed to log in to the specified server, continue anyway? (y/N) " CONTINUE if [ "$CONTINUE" != "y" ] ; then exit 1 fi fi if [ ${QUIET} == 0 ]; then echo echo "WARNING: this could take a long time if your depot is large" read -p "Do you want p4-search to index your depot on startup (y/N)? " SCAN else SCAN="y" fi if [ ! -d $ROOT ] ; then mkdir -p $ROOT fi if [ ! -e solr-$SOLR_VERSION.tgz ] ; then echo "Downloading solr-$SOLR_VERSION..." wget http://www.gtlib.gatech.edu/pub/apache/lucene/solr/4.5.1/solr-$SOLR_VERSION.tgz || exit 1 fi echo "Extracting solr..." tar xf solr-$SOLR_VERSION.tgz -C $ROOT || exit 1 if [ ! -e $JETTY_PATH.tar.gz ] ; then echo "Downloading $JETTY_PATH..." wget -O $JETTY_PATH.tar.gz "http://eclipse.org/downloads/download.php?file=/jetty/$JETTY_VERSION/dist/$JETTY_PATH.tar.gz&r=1" || exit 1 fi echo "Extracting jetty..." tar xf $JETTY_PATH.tar.gz -C $ROOT || exit 1 echo "Setting up solr..." # copy new schema for collection1, change the config to only do localhost cp -f ./solr-config/$SOLR_VERSION/schema.xml $ROOT/solr-$SOLR_VERSION/example/solr/collection1/conf/schema.xml || exit 1 echo "Updating control script" cat scripts/solr-control.sh | sed -e 's/JPORT=.*/JPORT=8983/' -e 's/STOP=.*/STOP=8984/' -e 's/#ROOT=ROOT_REPLACE/ROOT=${ROOT}/' -e 's/#SOLR_VERSION=SOLR_VERSION_REPLACE/SOLR_VERSION=${SOLR_VERSION}/' -e 's/#JETTY_VERSION=JETTY_VERSION_REPLACE/JETTY_VERSION=${JETTY_VERSION}/'> $ROOT/solr-$SOLR_VERSION/example/solr-control.sh && chmod +x $ROOT/solr-$SOLR_VERSION/example/solr-control.sh || exit 1 echo "Setting up p4-search..." # copy war, context.xml, etc. rm -rf $ROOT/$JETTY_PATH/webapps/* $ROOT/$JETTY_PATH/contexts/* cp p4-search*.war $ROOT/$JETTY_PATH/webapps/p4-search.war || exit 1 cp jetty/contexts/*.xml $ROOT/$JETTY_PATH/contexts || exit 1 cp scripts/p4search-control.sh $ROOT/$JETTY_PATH || exit 1 # TODO: somehow get the following into the solr jetty.xml file to lock the admin tool to local only # <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> # <Set name="handlers"> # <Array type="org.eclipse.jetty.server.Handler"> # <Item> # # <!-- here begins the new stuff --> # <New class="org.eclipse.jetty.server.handler.IPAccessHandler"> # <Call name="addWhite"><Arg>127.0.0.1</Arg></Call> # # <Set name="handler"> # <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> # </Set> # </New> # <!-- here ends the new stuff --> SEDARGS=" " if [ "$SCAN" != "y" ] ; then SEDARGS+="-e \"s/com.perforce.search.fileScannerToken\(.*\)/\# com.perforce.search.fileScannerToken\1/\"" else SEDARGS+="-e \"s/# com.perforce.search.fileScannerToken\(.*\)/com.perforce.search.fileScannerToken\1/\"" fi SEDARGS+=" -e \"s/serverHost=.*/serverHost=$HOST/\"" SEDARGS+=" -e \"s/serverPort=.*/serverPort=$PORT/\"" SEDARGS+=" -e \"s/indexerUser=.*/indexerUser=$LOGIN/\"" SEDARGS+=" -e \"s/indexerPassword=.*/indexerPassword=$PASS/\"" echo "Configuring p4-search ($SEDARGS)" eval sed $SEDARGS conf/search.config > $ROOT/$JETTY_PATH/resources/search.config if [ "$CHARSET" != "" ] ; then # append the charset to the config file echo "com.perforce.search.serverCharset=$CHARSET" >> $ROOT/$JETTY_PATH/resources/search.config fi echo "log4j.category.org.springframework=ERROR" >> $ROOT/$JETTY_PATH/resources/log4j.properties # generate the start.sh and stop.sh files ESC_ROOT="${ROOT//\//\\/}" ESC_SOLR="${SOLR_VERSION//\//\\/}" ESC_JETTY="${JETTY_PATH//\//\\/}" cat scripts/start.sh | sed -e 's/\$ROOT/'$ESC_ROOT'/' -e 's/\$SOLR_VERSION/'$ESC_SOLR'/' -e 's/\$JETTY_PATH/'$ESC_JETTY'/' > $ROOT/start.sh cat scripts/stop.sh | sed -e 's/\$ROOT/'$ESC_ROOT'/' -e 's/\$SOLR_VERSION/'$ESC_SOLR'/' -e 's/\$JETTY_PATH/'$ESC_JETTY'/' > $ROOT/stop.sh chmod +x $ROOT/start.sh $ROOT/stop.sh echo echo "To complete the installation you must install the trigger scripts/search-queue.sh in the server at $HOST:$PORT" echo "The trigger is required to signal to p4-search when indexing new content is required" echo echo "You can run $ROOT/start.sh at any time to start the services and connect to http://localhost:8088 in a web browser" echo
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 8501 | Doug Scheirer |
* updating to gradlew for build * make (more) Mac compatible build process * default port for default install is now 8088 * updated API doc to include the queryRaw param on POSTs * minor bug fixes for when the p4d connection drops while indexing |
||
#1 | 8476 | Doug Scheirer | p4-search copy from //depot/main/p4-search |