#!/bin/bash # # Copyright 2006 The Apache Software Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Shell script to force a optimized commit of all changes since last commit # for a Solr server orig_dir=$(pwd) cd ${0%/*}/.. solr_root=$(pwd) cd ${orig_dir} unset solr_port user verbose . ${solr_root}/bin/scripts-util # set up variables prog=${0##*/} log=${solr_root}/logs/${prog}.log # define usage string USAGE="\ usage: $prog [-p port] [-u username] [-v] -p specify Solr port number -u specify user to sudo to before running script -v increase verbosity " # parse args originalargs="$@" while getopts v OPTION do case $OPTION in p) solr_port="$OPTARG" ;; u) user="$OPTARG" ;; v) verbose="v" ;; *) echo "$USAGE" exit 1 esac done if [[ -z ${solr_port} ]] then echo "Solr port number missing in $confFile or command line." echo "$USAGE" exit 1 fi fixUser "$@" start=`date +"%s"` logMessage started by $oldwhoami logMessage command: $0 $@ rs=`curl http://localhost:${solr_port}/solr/update -s -d ""` if [[ $? != 0 ]] then logMessage failed to connect to Solr server at port ${solr_port} logMessage optimize failed logExit failed 1 fi # check status of optimize request rc=`echo $rs|cut -f2 -d'"'` if [[ $? != 0 ]] then logMessage optimize request to Solr at port ${solr_port} failed: logMessage $rs logExit failed 2 fi logExit ended 0