mirror of https://github.com/apache/lucene.git
added command line args for configuration
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@387613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4bcd07f79
commit
250e281eea
132
src/scripts/abc
132
src/scripts/abc
|
@ -1,45 +1,56 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/abc.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 make an Atomic Backup after Commit of
|
# Shell script to make an Atomic Backup after Commit of
|
||||||
# a Solr Lucene collection.
|
# a Solr Lucene collection.
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset solr_port data_dir user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-p port] [-d dir] [-u username] [-v]
|
||||||
|
-p specify Solr port number
|
||||||
|
-d specify directory holding index data
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts p:d:u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
p)
|
||||||
|
solr_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -48,41 +59,36 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
if [[ -z ${solr_port} ]]
|
||||||
|
then
|
||||||
|
echo "Solr port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# user default value for data_dir if not specified
|
||||||
|
# relative path starts at ${solr_root}
|
||||||
|
if [[ -z ${data_dir} ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
logMessage sending commit to Solr server at port 5051
|
logMessage sending commit to Solr server at port ${solr_port}
|
||||||
rs=`curl http://localhost:5051/update -s -d "<commit/>"`
|
rs=`curl http://localhost:${solr_port}/update -s -d "<commit/>"`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server at port ${solr_port}
|
||||||
logMessage commit failed
|
logMessage commit failed
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,42 +97,42 @@ fi
|
||||||
rc=`echo $rs|cut -f2 -d'"'`
|
rc=`echo $rs|cut -f2 -d'"'`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage commit request to Solr at port 5051 failed:
|
logMessage commit request to Solr at port ${solr_port} failed:
|
||||||
logMessage $rs
|
logMessage $rs
|
||||||
logExit failed 2
|
logExit failed 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# successful commit creates a snapshot file synchronously
|
# successful commit creates a snapshot file synchronously
|
||||||
lastsnap=`ls -drt1 snapshot.* 2> /dev/null | tail -1 `
|
lastsnap=`ls -drt1 ${data_dir}/snapshot.* 2> /dev/null | tail -1 `
|
||||||
|
|
||||||
if [[ $lastsnap == "" ]]
|
if [[ $lastsnap == "" ]]
|
||||||
then
|
then
|
||||||
logMessage commit did not create snapshot at port 5051; backup failed:
|
logMessage commit did not create snapshot at port ${solr_port}; backup failed:
|
||||||
logExit failed 3
|
logExit failed 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
name=backup.${lastsnap##snapshot.}
|
name=backup.${lastsnap##*snapshot.}
|
||||||
temp=temp-${name}
|
temp=temp-${name}
|
||||||
|
|
||||||
if [[ -d ${name} ]]
|
if [[ -d ${data_dir}/${name} ]]
|
||||||
then
|
then
|
||||||
logMessage backup directory ${name} already exists
|
logMessage backup directory ${data_dir}/${name} already exists
|
||||||
logExit aborted 1
|
logExit aborted 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d ${temp} ]]
|
if [[ -d ${data_dir}/${temp} ]]
|
||||||
then
|
then
|
||||||
logMessage backingup of ${name} in progress
|
logMessage backingup of ${data_dir}/${name} in progress
|
||||||
logExit aborted 1
|
logExit aborted 1
|
||||||
fi
|
fi
|
||||||
logMessage making backup ${name}
|
logMessage making backup ${data_dir}/${name}
|
||||||
|
|
||||||
# clean up after INT/TERM
|
# clean up after INT/TERM
|
||||||
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${name} ${temp};logExit aborted 13' INT TERM
|
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${data_dir}/${name} ${data_dir}/${temp};logExit aborted 13' INT TERM
|
||||||
|
|
||||||
# make a backup using hard links into temporary location
|
# make a backup using hard links into temporary location
|
||||||
# then move it into place atomically
|
# then move it into place atomically
|
||||||
cp -lr ${lastsnap} ${temp}
|
cp -lr ${lastsnap} ${data_dir}/${temp}
|
||||||
mv ${temp} ${name}
|
mv ${data_dir}/${temp} ${data_dir}/${name}
|
||||||
|
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
|
|
132
src/scripts/abo
132
src/scripts/abo
|
@ -1,45 +1,56 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/abo.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 make an Atomic Backup after Optimize of
|
# Shell script to make an Atomic Backup after Optimize of
|
||||||
# a Solr Lucene collection.
|
# a Solr Lucene collection.
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset solr_port data_dir user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-p port] [-d dir] [-u username] [-v]
|
||||||
|
-p specify Solr port number
|
||||||
|
-d specify directory holding index data
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts p:d:u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
p)
|
||||||
|
solr_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -48,41 +59,36 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
if [[ -z ${solr_port} ]]
|
||||||
|
then
|
||||||
|
echo "Solr port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# user default value for data_dir if not specified
|
||||||
|
# relative path starts at ${solr_root}
|
||||||
|
if [[ -z ${data_dir} ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
logMessage sending optimize to Solr server at port 5051
|
logMessage sending optimize to Solr server at port ${solr_port}
|
||||||
rs=`curl http://localhost:5051/update -s -d "<optimize/>"`
|
rs=`curl http://localhost:${solr_port}/update -s -d "<optimize/>"`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server at port ${solr_port}
|
||||||
logMessage optimize failed
|
logMessage optimize failed
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,42 +97,42 @@ fi
|
||||||
rc=`echo $rs|cut -f2 -d'"'`
|
rc=`echo $rs|cut -f2 -d'"'`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage optimize request to Solr at port 5051 failed:
|
logMessage optimize request to Solr at port ${solr_port} failed:
|
||||||
logMessage $rs
|
logMessage $rs
|
||||||
logExit failed 2
|
logExit failed 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# successful optimize creates a snapshot file synchronously
|
# successful optimize creates a snapshot file synchronously
|
||||||
lastsnap=`ls -drt1 snapshot.* | tail -1 `
|
lastsnap=`ls -drt1 ${data_dir}/snapshot.* | tail -1 `
|
||||||
|
|
||||||
if [[ $lastsnap == "" ]]
|
if [[ $lastsnap == "" ]]
|
||||||
then
|
then
|
||||||
logMessage commit did not create snapshot at port 5051; backup failed:
|
logMessage commit did not create snapshot at port ${solr_port}; backup failed:
|
||||||
logExit failed 3
|
logExit failed 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
name=backup.${lastsnap##snapshot.}
|
name=backup.${lastsnap##*snapshot.}
|
||||||
temp=temp-${name}
|
temp=temp-${name}
|
||||||
|
|
||||||
if [[ -d ${name} ]]
|
if [[ -d ${data_dir}/${name} ]]
|
||||||
then
|
then
|
||||||
logMessage backup directory ${name} already exists
|
logMessage backup directory ${data_dir}/${name} already exists
|
||||||
logExit aborted 1
|
logExit aborted 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d ${temp} ]]
|
if [[ -d ${data_dir}/${temp} ]]
|
||||||
then
|
then
|
||||||
logMessage backingup of ${name} in progress
|
logMessage backingup of ${data_dir}/${name} in progress
|
||||||
logExit aborted 1
|
logExit aborted 1
|
||||||
fi
|
fi
|
||||||
logMessage making backup ${name}
|
logMessage making backup ${data_dir}/${name}
|
||||||
|
|
||||||
# clean up after INT/TERM
|
# clean up after INT/TERM
|
||||||
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${name} ${temp};logExit aborted 13' INT TERM
|
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${data_dir}/${name} ${data_dir}/${temp};logExit aborted 13' INT TERM
|
||||||
|
|
||||||
# make a backup using hard links into temporary location
|
# make a backup using hard links into temporary location
|
||||||
# then move it into place atomically
|
# then move it into place atomically
|
||||||
cp -lr ${lastsnap} ${temp}
|
cp -lr ${lastsnap} ${data_dir}/${temp}
|
||||||
mv ${temp} ${name}
|
mv ${data_dir}/${temp} ${data_dir}/${name}
|
||||||
|
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
|
|
|
@ -1,46 +1,52 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/commit.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 commit of all changes since last commit
|
# Shell script to force a commit of all changes since last commit
|
||||||
# for a Solr server
|
# for a Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset solr_port user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-p port] [-u username] [-v]
|
||||||
|
-p specify Solr port number
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts p:u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
p)
|
||||||
|
solr_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -49,40 +55,25 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
if [[ -z ${solr_port} ]]
|
||||||
|
then
|
||||||
|
echo "Solr port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
rs=`curl http://localhost:5051/update -s -d "<commit/>"`
|
rs=`curl http://localhost:${solr_port}/update -s -d "<commit/>"`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server at port ${solr_port}
|
||||||
logMessage commit failed
|
logMessage commit failed
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,7 +82,7 @@ fi
|
||||||
rc=`echo $rs|cut -f2 -d'"'`
|
rc=`echo $rs|cut -f2 -d'"'`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage commit request to Solr at port 5051 failed:
|
logMessage commit request to Solr at port ${solr_port} failed:
|
||||||
logMessage $rs
|
logMessage $rs
|
||||||
logExit failed 2
|
logExit failed 2
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,46 +1,53 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/optimize.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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
|
# Shell script to force a optimized commit of all changes since last commit
|
||||||
# for a Solr server
|
# for a Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset solr_port user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-p port] [-u username] [-v]
|
||||||
|
-p specify Solr port number
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
originalargs="$@"
|
||||||
while getopts v OPTION
|
while getopts v OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
p)
|
||||||
|
solr_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -49,40 +56,25 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
if [[ -z ${solr_port} ]]
|
||||||
|
then
|
||||||
|
echo "Solr port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
rs=`curl http://localhost:5051/update -s -d "<optimize/>"`
|
rs=`curl http://localhost:${solr_port}/update -s -d "<optimize/>"`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server at port ${solr_port}
|
||||||
logMessage optimize failed
|
logMessage optimize failed
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,7 +83,7 @@ fi
|
||||||
rc=`echo $rs|cut -f2 -d'"'`
|
rc=`echo $rs|cut -f2 -d'"'`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage optimize request to Solr at port 5051 failed:
|
logMessage optimize request to Solr at port ${solr_port} failed:
|
||||||
logMessage $rs
|
logMessage $rs
|
||||||
logExit failed 2
|
logExit failed 2
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,46 +1,53 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/readercycle.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 all old readers closed and a new reader to be opened
|
# Shell script to force all old readers closed and a new reader to be opened
|
||||||
# for a Solr server
|
# for a Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset solr_port user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-p port] [-u username] [-v]
|
||||||
|
-p specify Solr port number
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
originalargs="$@"
|
||||||
while getopts v OPTION
|
while getopts p:u:v OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
p)
|
||||||
|
solr_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -49,40 +56,25 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
if [[ -z ${solr_port} ]]
|
||||||
|
then
|
||||||
|
echo "Solr port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
rs=`curl http://localhost:5051/update -s -d "<commit/>"`
|
rs=`curl http://localhost:${solr_port}/update -s -d "<commit/>"`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server at port ${solr_port}
|
||||||
logMessage reader cycle failed
|
logMessage reader cycle failed
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,7 +83,7 @@ fi
|
||||||
rc=`echo $rs|cut -f2 -d'"'`
|
rc=`echo $rs|cut -f2 -d'"'`
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage reader cycle request to Solr at port 5051 failed:
|
logMessage reader cycle request to Solr at port ${solr_port} failed:
|
||||||
logMessage $rs
|
logMessage $rs
|
||||||
logExit failed 2
|
logExit failed 2
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,44 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/rsyncd-disable.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 disable rsyncd
|
# Shell script to disable rsyncd
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/rsyncd.log
|
log=${solr_root}/logs/rsyncd.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-u username] [-v]
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -47,36 +50,14 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y/%m/%d %H:%M:%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage disabled by $oldwhoami
|
logMessage disabled by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
name=rsyncd-enabled
|
name=${solr_root}/logs/rsyncd-enabled
|
||||||
|
|
||||||
if [[ -f ${name} ]]
|
if [[ -f ${name} ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,44 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/rsyncd-enable.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 enable rsyncd
|
# Shell script to enable rsyncd
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
log=${solr_root}/logs/rsyncd.log
|
||||||
log=logs/rsyncd.log
|
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-u username] [-v]
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -47,36 +49,14 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y/%m/%d %H:%M:%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage enabled by $oldwhoami
|
logMessage enabled by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
name=rsyncd-enabled
|
name=${solr_root}/logs/rsyncd-enabled
|
||||||
|
|
||||||
if [[ -f ${name} ]]
|
if [[ -f ${name} ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,48 +1,55 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/rsyncd-start.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 start rsyncd on master Solr server
|
# Shell script to start rsyncd on master Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset data_dir solr_port rsyncd_port user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/rsyncd.log
|
log=${solr_root}/logs/rsyncd.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-d dir] [-p portnum] [-u username] [-v]
|
||||||
|
-d specify directory holding index data
|
||||||
|
-p specify rsyncd port number
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
resin_port=5051
|
|
||||||
rsyncd_port=`expr 10000 + ${resin_port}`
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts d:p:u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
rsyncd_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -51,26 +58,37 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
function timeStamp
|
fixUser "$@"
|
||||||
{
|
|
||||||
date +'%Y/%m/%d %H:%M:%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
# try to determine rsyncd port number from $confFile if not specified on
|
||||||
{
|
# command line
|
||||||
echo $(timeStamp) $@>>$log
|
if [[ -z ${rsyncd_port} ]]
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
then
|
||||||
echo $@
|
if [[ "${solr_port}" ]]
|
||||||
|
then
|
||||||
|
rsyncd_port=`expr 10000 + ${solr_port}`
|
||||||
|
else
|
||||||
|
echo "rsyncd port number missing in $confFile or command line."
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# user default value for data_dir if not specified
|
||||||
|
# relative path starts at ${solr_root}
|
||||||
|
if [[ -z ${data_dir} ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
logMessage started by $oldwhoami
|
logMessage started by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
if [[ ! -f rsyncd-enabled ]]
|
if [[ ! -f ${solr_root}/logs/rsyncd-enabled ]]
|
||||||
then
|
then
|
||||||
logMessage rsyncd disabled
|
logMessage rsyncd disabled
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -83,7 +101,26 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rsync --daemon --port=${rsyncd_port} --config=conf/rsyncd.conf
|
# create conf/rsyncd.conf on the fly, creating solrlogs directory if needed
|
||||||
|
if [[ ! -d ${solr_root}/conf ]]
|
||||||
|
then
|
||||||
|
mkdir ${solr_root}/conf
|
||||||
|
fi
|
||||||
|
cat <<EOF > ${solr_root}/conf/rsyncd.conf
|
||||||
|
#### rsyncd.conf file ####
|
||||||
|
|
||||||
|
uid = app
|
||||||
|
gid = app
|
||||||
|
use chroot = no
|
||||||
|
list = no
|
||||||
|
pid file = ${solr_root}/logs/rsyncd.pid
|
||||||
|
log file = ${solr_root}/logs/rsyncd.log
|
||||||
|
[solr]
|
||||||
|
path = ${data_dir}
|
||||||
|
comment = Solr
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rsync --daemon --port=${rsyncd_port} --config=${solr_root}/conf/rsyncd.conf
|
||||||
|
|
||||||
# first make sure rsyncd is accepting connections
|
# first make sure rsyncd is accepting connections
|
||||||
i=1
|
i=1
|
||||||
|
@ -98,4 +135,4 @@ do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
logMessage rsyncd started and accepting requests
|
logMessage rsyncd started with data_dir=${data_dir} and accepting requests
|
|
@ -1,46 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/rsyncd-stop.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 stop rsyncd on master Solr server
|
# Shell script to stop rsyncd on master Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/rsyncd.log
|
log=${solr_root}/logs/rsyncd.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-u username] [-v]
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
SERVER_ROOT=$(pwd)
|
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -49,27 +50,21 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
function timeStamp
|
fixUser "$@"
|
||||||
{
|
|
||||||
date +'%Y/%m/%d %H:%M:%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
logMessage stopped by $oldwhoami
|
logMessage stopped by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
|
|
||||||
|
# look for pid file
|
||||||
|
if [[ ! -f ${solr_root}/logs/rsyncd.pid ]]
|
||||||
|
then
|
||||||
|
logMessage "missing rsyncd pid file ${solr_root}/logs/rsyncd.pid"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
# get PID from file
|
# get PID from file
|
||||||
pid=$(<$SERVER_ROOT/logs/rsyncd.pid)
|
pid=$(<${solr_root}/logs/rsyncd.pid)
|
||||||
if [[ -z $pid ]]
|
if [[ -z $pid ]]
|
||||||
then
|
then
|
||||||
logMessage "unable to get rsyncd's PID"
|
logMessage "unable to get rsyncd's PID"
|
||||||
|
@ -98,3 +93,6 @@ then
|
||||||
logMessage rsyncd failed to stop after $timeout seconds
|
logMessage rsyncd failed to stop after $timeout seconds
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# remove rsyncd.conf
|
||||||
|
/bin/rm -f ${solr_root}/conf/rsyncd.conf
|
|
@ -1,53 +1,60 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snapcleaner.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 clean up snapshots of a Solr Lucene collection.
|
# Shell script to clean up snapshots of a Solr Lucene collection.
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset days num data_dir user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog -d <days> | -n <num> [ -v ]
|
usage: $prog -D <days> | -N <num> [-d dir] [-u username] [-v]
|
||||||
-d <days> cleanup snapshots more than <days> days old
|
-D <days> cleanup snapshots more than <days> days old
|
||||||
-n <num> keep the most most recent <num> number of snapshots and
|
-N <num> keep the most most recent <num> number of snapshots and
|
||||||
cleanup up the remaining ones that are not being pulled
|
cleanup up the remaining ones that are not being pulled
|
||||||
|
-d specify directory holding index data
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset days num verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts D:N:d:u:v OPTION
|
||||||
while getopts d:n:v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
d)
|
D)
|
||||||
days="$OPTARG"
|
days="$OPTARG"
|
||||||
;;
|
;;
|
||||||
n)
|
N)
|
||||||
num="$OPTARG"
|
num="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -56,7 +63,6 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
if [[ -z ${days} && -z ${num} ]]
|
if [[ -z ${days} && -z ${num} ]]
|
||||||
then
|
then
|
||||||
|
@ -64,31 +70,21 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function timeStamp
|
fixUser "$@"
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
# user default value for data_dir if not specified
|
||||||
{
|
# relative path starts at ${solr_root}
|
||||||
echo $(timeStamp) $@>>$log
|
if [[ -z ${data_dir} ]]
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
then
|
||||||
echo $@
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove
|
function remove
|
||||||
{
|
{
|
||||||
syncing=`ps -fwwwu app|grep rsync|grep -v grep|cut -f6 -d"/"|grep $1`
|
syncing=`ps -fwwwu ${user}|grep -w rsync|grep -v grep|grep -w $1`
|
||||||
if [[ -n $syncing ]]
|
if [[ -n $syncing ]]
|
||||||
then
|
then
|
||||||
logMessage $1 not removed - rsync in progress
|
logMessage $1 not removed - rsync in progress
|
||||||
|
@ -98,26 +94,26 @@ function remove
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage started by $oldwhoami
|
|
||||||
logMessage command: $0 $originalargs
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
|
logMessage started by $oldwhoami
|
||||||
|
logMessage command: $0 $@
|
||||||
|
|
||||||
# trap control-c
|
# trap control-c
|
||||||
trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already occured";logExit aborted 13' INT TERM
|
trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already occured";logExit aborted 13' INT TERM
|
||||||
|
|
||||||
if [[ -n ${days} ]]
|
if [[ -n ${days} ]]
|
||||||
then
|
then
|
||||||
logMessage cleaning up snapshots more than ${days} days old
|
logMessage cleaning up snapshots more than ${days} days old
|
||||||
for i in `find . -name "snapshot.*" -maxdepth 1 -mtime +${days} -print`
|
for i in `find ${data_dir} -name "snapshot.*" -maxdepth 1 -mtime +${days} -print`
|
||||||
do
|
do
|
||||||
remove `basename $i`
|
remove $i
|
||||||
done
|
done
|
||||||
elif [[ -n ${num} ]]
|
elif [[ -n ${num} ]]
|
||||||
then
|
then
|
||||||
logMessage cleaning up all snapshots except for the most recent ${num} ones
|
logMessage cleaning up all snapshots except for the most recent ${num} ones
|
||||||
unset snapshots count
|
unset snapshots count
|
||||||
snapshots=`ls -cd snapshot.* 2>/dev/null`
|
snapshots=`ls -cd ${data_dir}/snapshot.* 2>/dev/null`
|
||||||
if [[ $? == 0 ]]
|
if [[ $? == 0 ]]
|
||||||
then
|
then
|
||||||
count=`echo $snapshots|wc -w`
|
count=`echo $snapshots|wc -w`
|
||||||
|
|
|
@ -1,66 +1,60 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snapinstaller.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 install a snapshot into place as the Lucene collection
|
# Shell script to install a snapshot into place as the Lucene collection
|
||||||
# for a Solr server
|
# for a Solr server
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset master_host master_status_dir data_dir user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog -m master -p port [ -v ]
|
usage: $prog [-M master] [-S sdir] [-d dir] [-u username] [-v]
|
||||||
-m master hostname of master server where snapshot stats are posted
|
-M master specify hostname of master server from where to pull index
|
||||||
-p port port number of master server where snapshot stats are posted
|
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 increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
SERVER_ROOT=$(pwd)
|
|
||||||
|
|
||||||
unset masterHost masterPort verbose
|
|
||||||
|
|
||||||
# check for config file
|
|
||||||
confFile=${SERVER_ROOT}/conf/distribution.conf
|
|
||||||
if
|
|
||||||
[[ ! -f $confFile ]]
|
|
||||||
then
|
|
||||||
echo "unable to find configuration file: $confFile" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# source the config file
|
|
||||||
. $confFile
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts M:S:d:u:v OPTION
|
||||||
while getopts m:p:v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
m)
|
M)
|
||||||
masterHost="$OPTARG"
|
master_host="$OPTARG"
|
||||||
;;
|
;;
|
||||||
p)
|
S)
|
||||||
masterPort="$OPTARG"
|
master_status_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
|
@ -70,55 +64,49 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
MASTER_ROOT=/var/opt/resin3/${masterPort}
|
if [[ -z ${master_host} ]]
|
||||||
|
|
||||||
if [[ -z ${masterHost} ]]
|
|
||||||
then
|
then
|
||||||
echo "name of master server missing in $confFile or command line."
|
echo "name of master server missing in $confFile or command line."
|
||||||
echo "$USAGE"
|
echo "$USAGE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${masterPort} ]]
|
if [[ -z ${master_status_dir} ]]
|
||||||
then
|
then
|
||||||
echo "port number of master server missing in $confFile or command line."
|
echo "directory holding snapshot status on master server missing in $confFile or command line."
|
||||||
echo "$USAGE"
|
echo "$USAGE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function timeStamp
|
fixUser "$@"
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
# user default value for data_dir if not specified
|
||||||
{
|
# relative path starts at ${solr_root}
|
||||||
echo $(timeStamp) $@>>$log
|
if [[ -z ${data_dir} ]]
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
then
|
||||||
echo $@
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
# assume relative path to start at ${solr_root}
|
||||||
{
|
if [[ "`echo ${master_status_dir}|cut -c1`" != "/" ]]
|
||||||
end=`date +"%s"`
|
then
|
||||||
diff=`expr $end - $start`
|
master_status_dir=${solr_root}/${master_status_dir}
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
fi
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
logMessage started by $oldwhoami
|
|
||||||
logMessage command: $0 $originalargs
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
|
logMessage started by $oldwhoami
|
||||||
|
logMessage command: $0 $@
|
||||||
|
|
||||||
# get directory name of latest snapshot
|
# get directory name of latest snapshot
|
||||||
name=`ls -d snapshot.*|grep -v wip|sort -r|head -1`
|
name=`ls -d ${data_dir}/snapshot.* 2>/dev/null|grep -v wip|sort -r|head -1`
|
||||||
|
|
||||||
# clean up after INT/TERM
|
# clean up after INT/TERM
|
||||||
trap 'echo "caught INT/TERM, exiting now but partial installation may have already occured";/bin/rm -rf index.tmp$$;logExit aborted 13' INT TERM
|
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
|
# is there a snapshot
|
||||||
if [[ "${name}" == "" ]]
|
if [[ "${name}" == "" ]]
|
||||||
|
@ -128,7 +116,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# has snapshot already been installed
|
# has snapshot already been installed
|
||||||
if [[ ${name} == `cat logs/snapshot.current 2>/dev/null` ]]
|
if [[ ${name} == `cat ${solr_root}/logs/snapshot.current 2>/dev/null` ]]
|
||||||
then
|
then
|
||||||
logMessage latest snapshot ${name} already installed
|
logMessage latest snapshot ${name} already installed
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
|
@ -136,34 +124,34 @@ fi
|
||||||
|
|
||||||
# make sure master has directory for hold slaves stats/state
|
# make sure master has directory for hold slaves stats/state
|
||||||
if
|
if
|
||||||
! ssh -o StrictHostKeyChecking=no ${masterHost} mkdir -p ${MASTER_ROOT}/logs/clients
|
! ssh -o StrictHostKeyChecking=no ${master_host} mkdir -p ${master_status_dir}
|
||||||
then
|
then
|
||||||
logMessage failed to ssh to master ${masterHost}, snapshot status not updated on master
|
logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install using hard links into temporary directory
|
# install using hard links into temporary directory
|
||||||
# remove original index and then atomically copy new one into place
|
# remove original index and then atomically copy new one into place
|
||||||
logMessage installing snapshot ${name}
|
logMessage installing snapshot ${name}
|
||||||
cp -lr ${name}/ index.tmp$$
|
cp -lr ${name}/ ${data_dir}/index.tmp$$
|
||||||
/bin/rm -rf index
|
/bin/rm -rf ${data_dir}/index
|
||||||
mv -f index.tmp$$ index
|
mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
|
||||||
|
|
||||||
# update distribution stats
|
# update distribution stats
|
||||||
echo ${name} > logs/snapshot.current
|
echo ${name} > ${solr_root}/logs/snapshot.current
|
||||||
|
|
||||||
# push stats/state to master
|
# push stats/state to master
|
||||||
if
|
if
|
||||||
! scp -q -o StrictHostKeyChecking=no logs/snapshot.current ${masterHost}:${MASTER_ROOT}/logs/clients/snapshot.current.`uname -n`
|
! scp -q -o StrictHostKeyChecking=no ${solr_root}/logs/snapshot.current ${master_host}:${master_status_dir}/snapshot.current.`uname -n`
|
||||||
then
|
then
|
||||||
logMessage failed to ssh to master ${masterHost}, snapshot status not updated on master
|
logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# notify Solr to open a new Searcher
|
# notify Solr to open a new Searcher
|
||||||
logMessage notifing Solr to open a new Searcher
|
logMessage notifing Solr to open a new Searcher
|
||||||
scripts/solr/commit
|
${solr_root}/bin/commit
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage failed to connect to Solr server at port 5051
|
logMessage failed to connect to Solr server
|
||||||
logMessage snapshot installed but Solr server has not open a new Searcher
|
logMessage snapshot installed but Solr server has not open a new Searcher
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,71 +1,75 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snappuller.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 copy snapshots of a Solr Lucene collection from the master
|
# Shell script to copy snapshots of a Solr Lucene collection from the master
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset master_host rsyncd_port master_data_dir master_status_dir snap_name
|
||||||
if [[ $(whoami) != app ]]
|
unset sizeonly stats data_dir user verbose compress startStatus
|
||||||
then
|
. ${solr_root}/bin/scripts-util
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog -m master -p port [-n snapshot] [ -svz ]
|
usage: $prog [-M master] [-P portnum] [-D mdir] [-S sdir] [-n snapshot] [-d dir] [-u username] [-svz]
|
||||||
-m master hostname of master server from where to pull index snapshot
|
-M master specify hostname of master server from where to pull index
|
||||||
-p port port number of master server from where to pull index snapshot
|
snapshot
|
||||||
|
-P port specify rsyncd port number of master server from where to
|
||||||
|
pull index snapshot
|
||||||
|
-D specify directory holding index data on master server
|
||||||
|
-S specify directory holding snapshot status on master server
|
||||||
-n snapshot pull a specific snapshot by name
|
-n snapshot pull a specific snapshot by name
|
||||||
|
-d specify directory holding index data on local machine
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-s use the --size-only option with rsync
|
-s use the --size-only option with rsync
|
||||||
-v increase verbosity (-vv show file transfer stats also)
|
-v increase verbosity (-vv show file transfer stats also)
|
||||||
-z enable compression of data
|
-z enable compression of data
|
||||||
"
|
"
|
||||||
|
|
||||||
unset masterHost masterPort name sizeonly stats verbose compress startStatus
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
SERVER_ROOT=$(pwd)
|
|
||||||
|
|
||||||
# check for config file
|
|
||||||
confFile=${SERVER_ROOT}/conf/distribution.conf
|
|
||||||
if
|
|
||||||
[[ ! -f $confFile ]]
|
|
||||||
then
|
|
||||||
echo "unable to find configuration file: $confFile" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# source the config file
|
|
||||||
. $confFile
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts M:P:D:S:n:d:u:svz OPTION
|
||||||
while getopts m:p:n:svz OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
m)
|
M)
|
||||||
masterHost="$OPTARG"
|
master_host="$OPTARG"
|
||||||
;;
|
;;
|
||||||
p)
|
P)
|
||||||
masterPort="$OPTARG"
|
rsyncd_port="$OPTARG"
|
||||||
|
;;
|
||||||
|
D)
|
||||||
|
master_data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
S)
|
||||||
|
master_status_dir="$OPTARG"
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
name="$OPTARG"
|
snap_name="$OPTARG"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
sizeonly="--size-only"
|
sizeonly="--size-only"
|
||||||
|
@ -81,58 +85,69 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
MASTER_ROOT=/var/opt/resin3/${masterPort}
|
if [[ -z ${master_host} ]]
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
# push stats/state to master if necessary
|
|
||||||
if [[ -n ${startStatus} ]]
|
|
||||||
then
|
|
||||||
scp -q -o StrictHostKeyChecking=no logs/snappuller.status ${masterHost}:${MASTER_ROOT}/logs/clients/snapshot.status.`uname -n`
|
|
||||||
fi
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ -z ${masterHost} ]]
|
|
||||||
then
|
then
|
||||||
echo "name of master server missing in $confFile or command line."
|
echo "name of master server missing in $confFile or command line."
|
||||||
echo "$USAGE"
|
echo "$USAGE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${masterPort} ]]
|
if [[ -z ${rsyncd_port} ]]
|
||||||
then
|
then
|
||||||
echo "port number of master server missing in $confFile or command line."
|
echo "rsyncd port number of master server missing in $confFile or command line."
|
||||||
echo "$USAGE"
|
echo "$USAGE"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
rsyncd_port=`expr 10000 + ${masterPort}`
|
|
||||||
|
|
||||||
logMessage started by $oldwhoami
|
if [[ -z ${master_data_dir} ]]
|
||||||
logMessage command: $0 $originalargs
|
then
|
||||||
|
echo "directory holding index data on 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 "$@"
|
||||||
|
|
||||||
|
# user default value for data_dir if not specified
|
||||||
|
# relative path starts at ${solr_root}
|
||||||
|
if [[ -z ${data_dir} ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# assume relative path to start at ${solr_root}
|
||||||
|
if [[ "`echo ${master_data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
master_data_dir=${solr_root}/${master_data_dir}
|
||||||
|
fi
|
||||||
|
if [[ "`echo ${master_status_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
master_status_dir=${solr_root}/${master_status_dir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# push stats/state to master if necessary
|
||||||
|
function pushStatus
|
||||||
|
{
|
||||||
|
scp -q -o StrictHostKeyChecking=no ${solr_root}/logs/snappuller.status ${master_host}:${master_status_dir}/snapshot.status.`uname -n`
|
||||||
|
}
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
if [[ ! -f ${prog}-enabled ]]
|
logMessage started by $oldwhoami
|
||||||
|
logMessage command: $0 $@
|
||||||
|
|
||||||
|
if [[ ! -f ${solr_root}/logs/snappuller-enabled ]]
|
||||||
then
|
then
|
||||||
logMessage snappuller disabled
|
logMessage snappuller disabled
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -140,55 +155,61 @@ fi
|
||||||
|
|
||||||
# make sure we can ssh to master
|
# make sure we can ssh to master
|
||||||
if
|
if
|
||||||
! ssh -o StrictHostKeyChecking=no ${masterHost} id 1>/dev/null 2>&1
|
! ssh -o StrictHostKeyChecking=no ${master_host} id 1>/dev/null 2>&1
|
||||||
then
|
then
|
||||||
logMessage failed to ssh to master ${masterHost}
|
logMessage failed to ssh to master ${master_host}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get directory name of latest snapshot if not specified on command line
|
# get directory name of latest snapshot if not specified on command line
|
||||||
if [[ -z ${name} ]]
|
if [[ -z ${snap_name} ]]
|
||||||
then
|
then
|
||||||
name=`ssh -o StrictHostKeyChecking=no ${masterHost} "ls -d ${MASTER_ROOT}/snapshot.* 2>/dev/null"|tail -1`
|
snap_name=`ssh -o StrictHostKeyChecking=no ${master_host} "ls -d ${master_data_dir}/snapshot.* 2>/dev/null"|tail -1`
|
||||||
|
fi
|
||||||
|
if [[ "${snap_name}" == "" ]]
|
||||||
|
then
|
||||||
|
logMessage no snapshot available on ${master_host} in ${master_data_dir}
|
||||||
|
logExit ended 0
|
||||||
|
else
|
||||||
|
name=`basename ${snap_name}`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clean up after INT/TERM
|
# clean up after INT/TERM
|
||||||
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${name} ${name}-wip;echo ${startStatus} aborted:$(timeStamp)>logs/snappuller.status;logExit aborted 13' INT TERM
|
trap 'echo cleaning up, please wait ...;/bin/rm -rf ${data_dir}/${name} ${data_dir}/${name}-wip;echo ${startStatus} aborted:$(timeStamp)>${solr_root}/logs/snappuller.status;pushStatus;logExit aborted 13' INT TERM
|
||||||
|
|
||||||
if [[ -d ${name} || -d ${name}-wip || "${name}" == "" ]]
|
if [[ -d ${data_dir}/${name} || -d ${data_dir}/${name}-wip ]]
|
||||||
then
|
then
|
||||||
logMessage no new snapshot available on ${masterHost}:${masterPort}
|
logMessage no new snapshot available on ${master_host} in ${master_data_dir}
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# take a snapshot of current index so that only modified files will be rsync-ed
|
# take a snapshot of current index so that only modified files will be rsync-ed
|
||||||
# put the snapshot in the 'work-in-progress" directory to prevent it from
|
# put the snapshot in the 'work-in-progress" directory to prevent it from
|
||||||
# being installed while the copying is still in progress
|
# being installed while the copying is still in progress
|
||||||
cp -lr index ${name}-wip
|
cp -lr ${data_dir}/index ${data_dir}/${name}-wip
|
||||||
# force rsync of segments and .del files since we are doing size-only
|
# force rsync of segments and .del files since we are doing size-only
|
||||||
if [[ -n ${sizeonly} ]]
|
if [[ -n ${sizeonly} ]]
|
||||||
then
|
then
|
||||||
rm -f ${name}-wip/segments
|
rm -f ${data_dir}/${name}-wip/segments
|
||||||
rm -f ${name}-wip/*.del
|
rm -f ${data_dir}/${name}-wip/*.del
|
||||||
fi
|
fi
|
||||||
|
|
||||||
logMessage pulling snapshot ${name}
|
logMessage pulling snapshot ${name}
|
||||||
|
|
||||||
# make sure master has directory for hold slaves stats/state
|
# make sure master has directory for hold slaves stats/state
|
||||||
ssh -o StrictHostKeyChecking=no ${masterHost} mkdir -p ${MASTER_ROOT}/logs/clients
|
ssh -o StrictHostKeyChecking=no ${master_host} mkdir -p ${master_status_dir}
|
||||||
|
|
||||||
# start new distribution stats
|
# start new distribution stats
|
||||||
rsyncStart=`date`
|
rsyncStart=`date`
|
||||||
startTimestamp=`date -d "$rsyncStart" +'%Y%m%d-%H%M%S'`
|
startTimestamp=`date -d "$rsyncStart" +'%Y%m%d-%H%M%S'`
|
||||||
rsyncStartSec=`date -d "$rsyncStart" +'%s'`
|
rsyncStartSec=`date -d "$rsyncStart" +'%s'`
|
||||||
startStatus="rsync of `basename ${name}` started:$startTimestamp"
|
startStatus="rsync of `basename ${name}` started:$startTimestamp"
|
||||||
echo ${startStatus} > logs/snappuller.status
|
echo ${startStatus} > ${solr_root}/logs/snappuller.status
|
||||||
# push stats/state to master
|
pushStatus
|
||||||
scp -q -o StrictHostKeyChecking=no logs/snappuller.status ${masterHost}:${MASTER_ROOT}/logs/clients/snapshot.status.`uname -n`
|
|
||||||
|
|
||||||
# rsync over files that have changed
|
# rsync over files that have changed
|
||||||
rsync -Wa${verbose}${compress} --delete ${sizeonly} \
|
rsync -Wa${verbose}${compress} --delete ${sizeonly} \
|
||||||
${stats} rsync://${masterHost}:${rsyncd_port}/solr/`basename ${name}`/ `basename ${name}-wip`
|
${stats} rsync://${master_host}:${rsyncd_port}/solr/${name}/ ${data_dir}/${name}-wip
|
||||||
|
|
||||||
rc=$?
|
rc=$?
|
||||||
rsyncEnd=`date`
|
rsyncEnd=`date`
|
||||||
|
@ -198,15 +219,16 @@ elapsed=`expr $rsyncEndSec - $rsyncStartSec`
|
||||||
if [[ $rc != 0 ]]
|
if [[ $rc != 0 ]]
|
||||||
then
|
then
|
||||||
logMessage rsync failed
|
logMessage rsync failed
|
||||||
/bin/rm -rf ${name}-wip
|
/bin/rm -rf ${data_dir}/${name}-wip
|
||||||
echo ${startStatus} failed:$endTimestamp > logs/snappuller.status
|
echo ${startStatus} failed:$endTimestamp > ${solr_root}/logs/snappuller.status
|
||||||
|
pushStatus
|
||||||
logExit failed 1
|
logExit failed 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# move into place atomically
|
# move into place atomically
|
||||||
mv ${name}-wip ${name}
|
mv ${data_dir}/${name}-wip ${data_dir}/${name}
|
||||||
|
|
||||||
# finish new distribution stats`
|
# finish new distribution stats`
|
||||||
echo ${startStatus} ended:$endTimestamp rsync-elapsed:${elapsed} > logs/snappuller.status
|
echo ${startStatus} ended:$endTimestamp rsync-elapsed:${elapsed} > ${solr_root}/logs/snappuller.status
|
||||||
|
pushStatus
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
|
|
|
@ -1,44 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snappuller-disable.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 disable snappuller
|
# Shell script to disable snappuller
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/snappuller.log
|
log=${solr_root}/logs/snappuller.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-u username] [-v]
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -47,36 +50,14 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage disabled by $oldwhoami
|
logMessage disabled by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
name=snappuller-enabled
|
name=${solr_root}/logs/snappuller-enabled
|
||||||
|
|
||||||
if [[ -f ${name} ]]
|
if [[ -f ${name} ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,44 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snappuller-enable.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 enable snappuller
|
# Shell script to enable snappuller
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/snappuller.log
|
log=${solr_root}/logs/snappuller.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-u username] [-v]
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -47,36 +50,14 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
fixUser "$@"
|
||||||
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
function timeStamp
|
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
|
||||||
{
|
|
||||||
echo $(timeStamp) $@>>$log
|
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
|
||||||
echo $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
logMessage enabled by $oldwhoami
|
logMessage enabled by $oldwhoami
|
||||||
logMessage command: $0 $originalargs
|
logMessage command: $0 $@
|
||||||
name=snappuller-enabled
|
name=${solr_root}/logs/snappuller-enabled
|
||||||
|
|
||||||
if [[ -f ${name} ]]
|
if [[ -f ${name} ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,64 +1,51 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# $Id$
|
# Copyright 2006 The Apache Software Foundation
|
||||||
# $Source: /cvs/main/searching/solr-tools/snapshooter.template,v $
|
#
|
||||||
# $Name: r20050725_standardized_server_enabled $
|
# 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 take a snapshot of a Solr Lucene collection.
|
# Shell script to take a snapshot of a Solr Lucene collection.
|
||||||
|
|
||||||
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
orig_dir=$(pwd)
|
||||||
|
cd ${0%/*}/..
|
||||||
|
solr_root=$(pwd)
|
||||||
|
cd ${orig_dir}
|
||||||
|
|
||||||
# sudo to app user if necessary
|
unset data_dir user verbose
|
||||||
if [[ $(whoami) != app ]]
|
. ${solr_root}/bin/scripts-util
|
||||||
then
|
|
||||||
sudo -u app $0 "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
|
||||||
|
|
||||||
if [[ "${oldwhoami}" == "" ]]
|
|
||||||
then
|
|
||||||
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up variables
|
# set up variables
|
||||||
prog=${0##*/}
|
prog=${0##*/}
|
||||||
log=logs/${prog}.log
|
log=${solr_root}/logs/${prog}.log
|
||||||
|
|
||||||
# define usage string
|
# define usage string
|
||||||
USAGE="\
|
USAGE="\
|
||||||
usage: $prog [ -v ]
|
usage: $prog [-d dir] [-u username] [-v]
|
||||||
|
-d specify directory holding index data
|
||||||
|
-u specify user to sudo to before running script
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
"
|
"
|
||||||
|
|
||||||
cd ${0%/*}/../..
|
|
||||||
SERVER_ROOT=$(pwd)
|
|
||||||
|
|
||||||
unset verbose
|
|
||||||
|
|
||||||
# check for config file
|
|
||||||
confFile=${SERVER_ROOT}/conf/distribution.conf
|
|
||||||
if
|
|
||||||
[[ ! -f $confFile ]]
|
|
||||||
then
|
|
||||||
echo "unable to find configuration file: $confFile" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# source the config file
|
|
||||||
. $confFile
|
|
||||||
|
|
||||||
if [[ "${solr_role}" == "slave" ]]
|
|
||||||
then
|
|
||||||
echo "$prog disabled on slave server" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# parse args
|
# parse args
|
||||||
originalargs="$@"
|
while getopts d:u:v OPTION
|
||||||
while getopts v OPTION
|
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
|
d)
|
||||||
|
data_dir="$OPTARG"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
user="$OPTARG"
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
verbose="v"
|
verbose="v"
|
||||||
;;
|
;;
|
||||||
|
@ -67,36 +54,27 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
function timeStamp
|
fixUser "$@"
|
||||||
{
|
|
||||||
date +'%Y%m%d-%H%M%S'
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMessage
|
# user default value for data_dir if not specified
|
||||||
{
|
# relative path starts at ${solr_root}
|
||||||
echo $(timeStamp) $@>>$log
|
if [[ -z ${data_dir} ]]
|
||||||
if [[ -n ${verbose} ]]
|
|
||||||
then
|
then
|
||||||
echo $@
|
data_dir=${solr_root}/data
|
||||||
|
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
||||||
|
then
|
||||||
|
data_dir=${solr_root}/${data_dir}
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
function logExit
|
|
||||||
{
|
|
||||||
end=`date +"%s"`
|
|
||||||
diff=`expr $end - $start`
|
|
||||||
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
|
||||||
exit $2
|
|
||||||
}
|
|
||||||
|
|
||||||
logMessage started by $oldwhoami
|
|
||||||
logMessage command: $0 $originalargs
|
|
||||||
start=`date +"%s"`
|
start=`date +"%s"`
|
||||||
|
|
||||||
name=snapshot.`date +"%Y%m%d%H%M%S"`
|
logMessage started by $oldwhoami
|
||||||
temp=temp-${name}
|
logMessage command: $0 $@
|
||||||
|
|
||||||
|
snap_name=snapshot.`date +"%Y%m%d%H%M%S"`
|
||||||
|
name=${data_dir}/${snap_name}
|
||||||
|
temp=${data_dir}/temp-${snap_name}
|
||||||
|
|
||||||
if [[ -d ${name} ]]
|
if [[ -d ${name} ]]
|
||||||
then
|
then
|
||||||
|
@ -117,7 +95,7 @@ logMessage taking snapshot ${name}
|
||||||
|
|
||||||
# take a snapshot using hard links into temporary location
|
# take a snapshot using hard links into temporary location
|
||||||
# then move it into place atomically
|
# then move it into place atomically
|
||||||
cp -lr index ${temp}
|
cp -lr ${data_dir}/index ${temp}
|
||||||
mv ${temp} ${name}
|
mv ${temp} ${name}
|
||||||
|
|
||||||
logExit ended 0
|
logExit ended 0
|
||||||
|
|
Loading…
Reference in New Issue