#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
#
# 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 install a snapshot into place as the Lucene collection
# for a Solr server
orig_dir=$(pwd)
cd ${0%/*}/..
solr_root=$(pwd)
cd ${orig_dir}
# set up variables
LOCKDIR="${solr_root}/logs/snapinstaller-lock"
PIDFILE="${LOCKDIR}/PID"
# define usage string
USAGE="\
usage: $prog [-M master] [-S sdir] [-d dir] [-u username] [-v] [-V]
-M master specify hostname of master server from where to pull index
snapshot
-S specify directory holding snapshot status on master server
-d specify directory holding index data on local machine
-u specify user to sudo to before running script
-v increase verbosity
-V output debugging info
"
# parse args
do
M)
;;
S)
;;
d)
;;
u)
;;
v)
verbose="v"
;;
V)
debug="V"
;;
*)
echo "$USAGE"
exit 1
esac
done
[[ -n $debug ]] && set -x
if [[ -z ${master_host} ]]
then
echo "name of master server missing in $confFile or command line."
echo "$USAGE"
exit 1
fi
if [[ -z ${master_status_dir} ]]
then
echo "directory holding snapshot status on master server missing in $confFile or command line."
echo "$USAGE"
exit 1
fi
fixUser "$@"
# assume relative path to start at ${solr_root}
then
fi
if test -r $PIDFILE
then
else
fi
fi
echo "$$" >"${PIDFILE}"
logMessage command: $0 $@
# get directory name of latest snapshot
name=`perl -e 'chdir q|'${data_dir}'|; print ((sort grep {/^snapshot[.][1-9][0-9]{13}$/} <*>)[-1])'`
trap 'echo "caught INT/TERM, exiting now but partial installation may have already occured";/bin/rm -rf ${data_dir}/index.tmp$$;logExit aborted 13' INT TERM
# is there a snapshot
if [[ "${name}" == "" ]]
then
fi
# has snapshot already been installed
then
fi
if
then
fi
# install using hard links into temporary directory
# remove original index and then atomically copy new one into place
if [[ "${OS}" == "SunOS" || "${OS}" == "Darwin" || "${OS}" == "FreeBSD" ]]
then
orig_dir=$(pwd)
cd ${name} && \
cd ${orig_dir}
else
fi
# update distribution stats
if
! scp -q -o StrictHostKeyChecking=no ${solr_root}/logs/snapshot.current ${master_host}:${master_status_dir}/snapshot.current.`uname -n`
then
fi
# notify Solr to open a new Searcher
if [[ $? != 0 ]]
then
fi