From: Dennis Schafroth Date: Fri, 29 Nov 2013 13:43:59 +0000 (+0100) Subject: Improve configuration from options file. X-Git-Tag: v0.6.0~6^2~10 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=ab565e092d2c9c67cff971cc93cf77407adefec4;p=lui-solr.git Improve configuration from options file. --- diff --git a/scripts/zookeeper.sh b/scripts/zookeeper.sh index 8e48202..49ba073 100755 --- a/scripts/zookeeper.sh +++ b/scripts/zookeeper.sh @@ -1,15 +1,41 @@ #/bin/bash -OPTIONS="-Djetty.port=8983 -DzkHost=opencontent-solr.index:9983" -NAME="indexdata-solr-zookeeper" +NAME="indexdata-lui-solr-zookeeper" +HOST=localhost +PORT=8983 +SHARDS=2 PID_FILE=/var/run/${NAME}.pid LOG_FILE=/var/log/${NAME}.log -if [ -f "options" ]; then - source options +ZOOKEEPER=yes +OPTIONS=${OPTIONS:-options} + +if [ -f "$OPTIONS" ]; then + source $OPTIONS else - echo "No options file. Using defaults: $OPTIONS" + echo "No options file ($OPTIONS). Using defaults." +fi +let ZKPORT=$PORT+1000 +if [ "$ZKHOSTS" == "" ] ; then + ZKHOSTS=${HOST}:${ZKPORT} fi +if [ "$BOOTSTRAP_CONF" != "" ] ; then + BOOTSTRAP_OPT="-Dbootstrap_confdir=$BOOTSTRAP_CONF" +fi +if [ "$PORT" == "" ] ; then + echo Port missing + +fi +if [ "$ZKHOSTS" == "" ] ; then + echo ZKHOSTS missing +fi +if [ "$SHARDS" == "" ] ; then + echo SHARDS missing +fi +if [ "$ZOOKEEPER" == "yes" ] ; then + ZKRUN="-DzkRun -DnumShards=${SHARDS}" +fi +OPTIONS=" -Djetty.port=$PORT ${BOOTSTRAP_OPT} -Dcollection.configName=$NAME ${ZKRUN} -DzkHost=${ZKHOSTS} " if [ "$1" == "start" ]; then if [ -f "${PID_FILE}" ] ; then echo "pid file ${PID_FILE} exists. Already running?" @@ -18,9 +44,11 @@ if [ "$1" == "start" ]; then java $OPTIONS -jar start.jar > $LOG_FILE & echo $! > ${PID_FILE} elif [ "$1" == "stop" ]; then - if [ -x "${PID_FILE}" ] ; then - kill `echo ${PID_FILE}` + if [ -f "${PID_FILE}" ] ; then + kill `cat ${PID_FILE}` rm ${PID_FILE} + else + echo "No pid file ($PID_FILE) found" fi else echo "$0 [start|stop|status]"