diff --git a/src/scripts/abc b/src/scripts/abc
index 5f22207d714..a9ac2fbb398 100755
--- a/src/scripts/abc
+++ b/src/scripts/abc
@@ -1,45 +1,56 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/abc.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to make an Atomic Backup after Commit 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
-if [[ $(whoami) != app ]]
-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
+unset solr_port data_dir user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts p:d:u:v OPTION
do
case $OPTION in
+ p)
+ solr_port="$OPTARG"
+ ;;
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -48,41 +59,36 @@ do
exit 1
esac
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"`
-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 command: $0 $originalargs
+logMessage command: $0 $@
-logMessage sending commit to Solr server at port 5051
-rs=`curl http://localhost:5051/update -s -d ""`
+logMessage sending commit to Solr server at port ${solr_port}
+rs=`curl http://localhost:${solr_port}/update -s -d ""`
if [[ $? != 0 ]]
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
logExit failed 1
fi
@@ -91,42 +97,42 @@ fi
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
- logMessage commit request to Solr at port 5051 failed:
+ logMessage commit request to Solr at port ${solr_port} failed:
logMessage $rs
logExit failed 2
fi
# 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 == "" ]]
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
fi
-name=backup.${lastsnap##snapshot.}
+name=backup.${lastsnap##*snapshot.}
temp=temp-${name}
-if [[ -d ${name} ]]
+if [[ -d ${data_dir}/${name} ]]
then
- logMessage backup directory ${name} already exists
+ logMessage backup directory ${data_dir}/${name} already exists
logExit aborted 1
fi
-if [[ -d ${temp} ]]
+if [[ -d ${data_dir}/${temp} ]]
then
- logMessage backingup of ${name} in progress
+ logMessage backingup of ${data_dir}/${name} in progress
logExit aborted 1
fi
-logMessage making backup ${name}
+logMessage making backup ${data_dir}/${name}
# 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
# then move it into place atomically
-cp -lr ${lastsnap} ${temp}
-mv ${temp} ${name}
+cp -lr ${lastsnap} ${data_dir}/${temp}
+mv ${data_dir}/${temp} ${data_dir}/${name}
logExit ended 0
diff --git a/src/scripts/abo b/src/scripts/abo
index 524cb92f8d9..1327f7c13c9 100755
--- a/src/scripts/abo
+++ b/src/scripts/abo
@@ -1,45 +1,56 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/abo.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to make an Atomic Backup after Optimize 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
-if [[ $(whoami) != app ]]
-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
+unset solr_port data_dir user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts p:d:u:v OPTION
do
case $OPTION in
+ p)
+ solr_port="$OPTARG"
+ ;;
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -48,41 +59,36 @@ do
exit 1
esac
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"`
-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 command: $0 $originalargs
+logMessage command: $0 $@
-logMessage sending optimize to Solr server at port 5051
-rs=`curl http://localhost:5051/update -s -d ""`
+logMessage sending optimize to Solr server at port ${solr_port}
+rs=`curl http://localhost:${solr_port}/update -s -d ""`
if [[ $? != 0 ]]
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
logExit failed 1
fi
@@ -91,42 +97,42 @@ fi
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
- logMessage optimize request to Solr at port 5051 failed:
+ logMessage optimize request to Solr at port ${solr_port} failed:
logMessage $rs
logExit failed 2
fi
# successful optimize creates a snapshot file synchronously
-lastsnap=`ls -drt1 snapshot.* | tail -1 `
+lastsnap=`ls -drt1 ${data_dir}/snapshot.* | tail -1 `
if [[ $lastsnap == "" ]]
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
fi
-name=backup.${lastsnap##snapshot.}
+name=backup.${lastsnap##*snapshot.}
temp=temp-${name}
-if [[ -d ${name} ]]
+if [[ -d ${data_dir}/${name} ]]
then
- logMessage backup directory ${name} already exists
+ logMessage backup directory ${data_dir}/${name} already exists
logExit aborted 1
fi
-if [[ -d ${temp} ]]
+if [[ -d ${data_dir}/${temp} ]]
then
- logMessage backingup of ${name} in progress
+ logMessage backingup of ${data_dir}/${name} in progress
logExit aborted 1
fi
-logMessage making backup ${name}
+logMessage making backup ${data_dir}/${name}
# 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
# then move it into place atomically
-cp -lr ${lastsnap} ${temp}
-mv ${temp} ${name}
+cp -lr ${lastsnap} ${data_dir}/${temp}
+mv ${data_dir}/${temp} ${data_dir}/${name}
logExit ended 0
diff --git a/src/scripts/commit b/src/scripts/commit
index aa6fa505fc9..b69bf459e88 100755
--- a/src/scripts/commit
+++ b/src/scripts/commit
@@ -1,46 +1,52 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/commit.template,v $
-# $Name: r20050725_standardized_server_enabled $
-
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to force a commit of all changes since last commit
# 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
-if [[ $(whoami) != app ]]
-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
+unset solr_port user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts p:u:v OPTION
do
case $OPTION in
+ p)
+ solr_port="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -49,40 +55,25 @@ do
exit 1
esac
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"`
-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 command: $0 $originalargs
+logMessage command: $0 $@
-rs=`curl http://localhost:5051/update -s -d ""`
+rs=`curl http://localhost:${solr_port}/update -s -d ""`
if [[ $? != 0 ]]
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
logExit failed 1
fi
@@ -91,7 +82,7 @@ fi
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
- logMessage commit request to Solr at port 5051 failed:
+ logMessage commit request to Solr at port ${solr_port} failed:
logMessage $rs
logExit failed 2
fi
diff --git a/src/scripts/optimize b/src/scripts/optimize
index 559fd61039d..ae315b71e06 100755
--- a/src/scripts/optimize
+++ b/src/scripts/optimize
@@ -1,46 +1,53 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/optimize.template,v $
-# $Name: r20050725_standardized_server_enabled $
-
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to force a optimized commit of all changes since last commit
# for a Solr server
-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
-if [[ $(whoami) != app ]]
-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
+unset solr_port user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-unset verbose
-
# parse args
originalargs="$@"
while getopts v OPTION
do
case $OPTION in
+ p)
+ solr_port="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -49,40 +56,25 @@ do
exit 1
esac
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"`
-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 command: $0 $originalargs
+logMessage command: $0 $@
-rs=`curl http://localhost:5051/update -s -d ""`
+rs=`curl http://localhost:${solr_port}/update -s -d ""`
if [[ $? != 0 ]]
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
logExit failed 1
fi
@@ -91,7 +83,7 @@ fi
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
- logMessage optimize request to Solr at port 5051 failed:
+ logMessage optimize request to Solr at port ${solr_port} failed:
logMessage $rs
logExit failed 2
fi
diff --git a/src/scripts/readercycle b/src/scripts/readercycle
index 7603b3afa73..e920580968b 100755
--- a/src/scripts/readercycle
+++ b/src/scripts/readercycle
@@ -1,46 +1,53 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/readercycle.template,v $
-# $Name: r20050725_standardized_server_enabled $
-
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to force all old readers closed and a new reader to be opened
# 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
-if [[ $(whoami) != app ]]
-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
+unset solr_port user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-unset verbose
-
# parse args
originalargs="$@"
-while getopts v OPTION
+while getopts p:u:v OPTION
do
case $OPTION in
+ p)
+ solr_port="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -49,40 +56,25 @@ do
exit 1
esac
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"`
-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 command: $0 $originalargs
+logMessage command: $0 $@
-rs=`curl http://localhost:5051/update -s -d ""`
+rs=`curl http://localhost:${solr_port}/update -s -d ""`
if [[ $? != 0 ]]
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
logExit failed 1
fi
@@ -91,7 +83,7 @@ fi
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
- logMessage reader cycle request to Solr at port 5051 failed:
+ logMessage reader cycle request to Solr at port ${solr_port} failed:
logMessage $rs
logExit failed 2
fi
diff --git a/src/scripts/rsyncd-disable b/src/scripts/rsyncd-disable
index 08c20e704e3..4d6bb39d843 100755
--- a/src/scripts/rsyncd-disable
+++ b/src/scripts/rsyncd-disable
@@ -1,44 +1,47 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/rsyncd-disable.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/rsyncd.log
+log=${solr_root}/logs/rsyncd.log
# define usage string
USAGE="\
-usage: $prog [ -v ]
+usage: $prog [-u username] [-v]
+ -u specify user to sudo to before running script
-v increase verbosity
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts u:v OPTION
do
case $OPTION in
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -47,36 +50,14 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
+
+fixUser "$@"
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 command: $0 $originalargs
-name=rsyncd-enabled
+logMessage command: $0 $@
+name=${solr_root}/logs/rsyncd-enabled
if [[ -f ${name} ]]
then
diff --git a/src/scripts/rsyncd-enable b/src/scripts/rsyncd-enable
index baa4d72c145..488145879f4 100755
--- a/src/scripts/rsyncd-enable
+++ b/src/scripts/rsyncd-enable
@@ -1,44 +1,46 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/rsyncd-enable.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
-prog=${0##*/}
-log=logs/rsyncd.log
+log=${solr_root}/logs/rsyncd.log
# define usage string
USAGE="\
-usage: $prog [ -v ]
+usage: $prog [-u username] [-v]
+ -u specify user to sudo to before running script
-v increase verbosity
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts u:v OPTION
do
case $OPTION in
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -47,36 +49,14 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
+
+fixUser "$@"
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 command: $0 $originalargs
-name=rsyncd-enabled
+logMessage command: $0 $@
+name=${solr_root}/logs/rsyncd-enabled
if [[ -f ${name} ]]
then
diff --git a/src/scripts/rsyncd-start b/src/scripts/rsyncd-start
index a2f16eb0d89..8254cf0e304 100755
--- a/src/scripts/rsyncd-start
+++ b/src/scripts/rsyncd-start
@@ -1,48 +1,55 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/rsyncd-start.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset data_dir solr_port rsyncd_port user verbose
+. ${solr_root}/bin/scripts-util
+# set up variables
prog=${0##*/}
-log=logs/rsyncd.log
+log=${solr_root}/logs/rsyncd.log
# define usage string
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
"
-resin_port=5051
-rsyncd_port=`expr 10000 + ${resin_port}`
-
-cd ${0%/*}/../..
-
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts d:p:u:v OPTION
do
case $OPTION in
+ d)
+ data_dir="$OPTARG"
+ ;;
+ p)
+ rsyncd_port="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -51,26 +58,37 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
-function timeStamp
-{
- date +'%Y/%m/%d %H:%M:%S'
-}
+fixUser "$@"
-function logMessage
-{
- echo $(timeStamp) $@>>$log
- if [[ -n ${verbose} ]]
+# try to determine rsyncd port number from $confFile if not specified on
+# command line
+if [[ -z ${rsyncd_port} ]]
+then
+ if [[ "${solr_port}" ]]
then
- echo $@
+ 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
logMessage started by $oldwhoami
-logMessage command: $0 $originalargs
+logMessage command: $0 $@
-if [[ ! -f rsyncd-enabled ]]
+if [[ ! -f ${solr_root}/logs/rsyncd-enabled ]]
then
logMessage rsyncd disabled
exit 1
@@ -83,7 +101,26 @@ then
exit 1
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 < ${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
i=1
@@ -98,4 +135,4 @@ do
sleep 1
done
-logMessage rsyncd started and accepting requests
\ No newline at end of file
+logMessage rsyncd started with data_dir=${data_dir} and accepting requests
\ No newline at end of file
diff --git a/src/scripts/rsyncd-stop b/src/scripts/rsyncd-stop
index 672ae92fd4b..04177b371cd 100755
--- a/src/scripts/rsyncd-stop
+++ b/src/scripts/rsyncd-stop
@@ -1,46 +1,47 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/rsyncd-stop.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset user verbose
+. ${solr_root}/bin/scripts-util
+# set up variables
prog=${0##*/}
-log=logs/rsyncd.log
+log=${solr_root}/logs/rsyncd.log
# define usage string
USAGE="\
-usage: $prog [ -v ]
+usage: $prog [-u username] [-v]
+ -u specify user to sudo to before running script
-v increase verbosity
"
-cd ${0%/*}/../..
-SERVER_ROOT=$(pwd)
-
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts u:v OPTION
do
case $OPTION in
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -49,27 +50,21 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
-function timeStamp
-{
- date +'%Y/%m/%d %H:%M:%S'
-}
-
-function logMessage
-{
- echo $(timeStamp) $@>>$log
- if [[ -n ${verbose} ]]
- then
- echo $@
- fi
-}
+fixUser "$@"
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
-pid=$(<$SERVER_ROOT/logs/rsyncd.pid)
+pid=$(<${solr_root}/logs/rsyncd.pid)
if [[ -z $pid ]]
then
logMessage "unable to get rsyncd's PID"
@@ -98,3 +93,6 @@ then
logMessage rsyncd failed to stop after $timeout seconds
exit 3
fi
+
+# remove rsyncd.conf
+/bin/rm -f ${solr_root}/conf/rsyncd.conf
\ No newline at end of file
diff --git a/src/scripts/snapcleaner b/src/scripts/snapcleaner
index cabb88cea49..9a88f5a8277 100755
--- a/src/scripts/snapcleaner
+++ b/src/scripts/snapcleaner
@@ -1,53 +1,60 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snapcleaner.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset days num data_dir user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
USAGE="\
-usage: $prog -d | -n [ -v ]
- -d cleanup snapshots more than days old
- -n keep the most most recent number of snapshots and
- cleanup up the remaining ones that are not being pulled
- -v increase verbosity
+usage: $prog -D | -N [-d dir] [-u username] [-v]
+ -D cleanup snapshots more than days old
+ -N keep the most most recent number of snapshots and
+ 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
"
-unset days num verbose
-
# parse args
-originalargs="$@"
-while getopts d:n:v OPTION
+while getopts D:N:d:u:v OPTION
do
case $OPTION in
- d)
+ D)
days="$OPTARG"
;;
- n)
+ N)
num="$OPTARG"
;;
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -56,7 +63,6 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
if [[ -z ${days} && -z ${num} ]]
then
@@ -64,31 +70,21 @@ then
exit 1
fi
-function timeStamp
-{
- date +'%Y%m%d-%H%M%S'
-}
+fixUser "$@"
-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
-}
+# 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
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 ]]
then
logMessage $1 not removed - rsync in progress
@@ -98,26 +94,26 @@ function remove
fi
}
-cd ${0%/*}/../..
-logMessage started by $oldwhoami
-logMessage command: $0 $originalargs
start=`date +"%s"`
+logMessage started by $oldwhoami
+logMessage command: $0 $@
+
# trap control-c
trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already occured";logExit aborted 13' INT TERM
if [[ -n ${days} ]]
then
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
- remove `basename $i`
+ remove $i
done
elif [[ -n ${num} ]]
then
logMessage cleaning up all snapshots except for the most recent ${num} ones
unset snapshots count
- snapshots=`ls -cd snapshot.* 2>/dev/null`
+ snapshots=`ls -cd ${data_dir}/snapshot.* 2>/dev/null`
if [[ $? == 0 ]]
then
count=`echo $snapshots|wc -w`
diff --git a/src/scripts/snapinstaller b/src/scripts/snapinstaller
index 68d63a52212..c445c0f8595 100755
--- a/src/scripts/snapinstaller
+++ b/src/scripts/snapinstaller
@@ -1,66 +1,60 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snapinstaller.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to install a snapshot into place as the Lucene collection
# 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
-if [[ $(whoami) != app ]]
-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
+unset master_host master_status_dir data_dir user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
USAGE="\
-usage: $prog -m master -p port [ -v ]
- -m master hostname of master server where snapshot stats are posted
- -p port port number of master server where snapshot stats are posted
+usage: $prog [-M master] [-S sdir] [-d dir] [-u username] [-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
"
-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
-originalargs="$@"
-while getopts m:p:v OPTION
+while getopts M:S:d:u:v OPTION
do
case $OPTION in
- m)
- masterHost="$OPTARG"
+ M)
+ master_host="$OPTARG"
;;
- p)
- masterPort="$OPTARG"
+ S)
+ master_status_dir="$OPTARG"
+ ;;
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
;;
v)
verbose="v"
@@ -70,55 +64,49 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
-MASTER_ROOT=/var/opt/resin3/${masterPort}
-
-if [[ -z ${masterHost} ]]
+if [[ -z ${master_host} ]]
then
echo "name of master server missing in $confFile or command line."
echo "$USAGE"
exit 1
fi
-
-if [[ -z ${masterPort} ]]
+
+if [[ -z ${master_status_dir} ]]
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"
exit 1
fi
-function timeStamp
-{
- date +'%Y%m%d-%H%M%S'
-}
+fixUser "$@"
-function logMessage
-{
- echo $(timeStamp) $@>>$log
- if [[ -n ${verbose} ]]
- then
- echo $@
- 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
-function logExit
-{
- end=`date +"%s"`
- diff=`expr $end - $start`
- echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
- exit $2
-}
+# assume relative path to start at ${solr_root}
+if [[ "`echo ${master_status_dir}|cut -c1`" != "/" ]]
+then
+ master_status_dir=${solr_root}/${master_status_dir}
+fi
-logMessage started by $oldwhoami
-logMessage command: $0 $originalargs
start=`date +"%s"`
+logMessage started by $oldwhoami
+logMessage command: $0 $@
+
# 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
-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
if [[ "${name}" == "" ]]
@@ -128,7 +116,7 @@ then
fi
# 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
logMessage latest snapshot ${name} already installed
logExit ended 0
@@ -136,34 +124,34 @@ fi
# make sure master has directory for hold slaves stats/state
if
- ! ssh -o StrictHostKeyChecking=no ${masterHost} mkdir -p ${MASTER_ROOT}/logs/clients
+ ! ssh -o StrictHostKeyChecking=no ${master_host} mkdir -p ${master_status_dir}
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
# install using hard links into temporary directory
# remove original index and then atomically copy new one into place
logMessage installing snapshot ${name}
-cp -lr ${name}/ index.tmp$$
-/bin/rm -rf index
-mv -f index.tmp$$ index
+cp -lr ${name}/ ${data_dir}/index.tmp$$
+/bin/rm -rf ${data_dir}/index
+mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
# update distribution stats
-echo ${name} > logs/snapshot.current
+echo ${name} > ${solr_root}/logs/snapshot.current
# push stats/state to master
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
- 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
# notify Solr to open a new Searcher
logMessage notifing Solr to open a new Searcher
-scripts/solr/commit
+${solr_root}/bin/commit
if [[ $? != 0 ]]
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
logExit failed 1
fi
diff --git a/src/scripts/snappuller b/src/scripts/snappuller
index 0d14f6711f4..7d90420c507 100755
--- a/src/scripts/snappuller
+++ b/src/scripts/snappuller
@@ -1,71 +1,75 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snappuller.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset master_host rsyncd_port master_data_dir master_status_dir snap_name
+unset sizeonly stats data_dir user verbose compress startStatus
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
USAGE="\
-usage: $prog -m master -p port [-n snapshot] [ -svz ]
- -m master hostname of master server from where to pull index snapshot
- -p port port number of master server from where to pull index snapshot
+usage: $prog [-M master] [-P portnum] [-D mdir] [-S sdir] [-n snapshot] [-d dir] [-u username] [-svz]
+ -M master specify hostname of master server from where to pull index
+ 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
+ -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
-v increase verbosity (-vv show file transfer stats also)
-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
-originalargs="$@"
-while getopts m:p:n:svz OPTION
+while getopts M:P:D:S:n:d:u:svz OPTION
do
case $OPTION in
- m)
- masterHost="$OPTARG"
+ M)
+ master_host="$OPTARG"
;;
- p)
- masterPort="$OPTARG"
+ P)
+ rsyncd_port="$OPTARG"
+ ;;
+ D)
+ master_data_dir="$OPTARG"
+ ;;
+ S)
+ master_status_dir="$OPTARG"
;;
n)
- name="$OPTARG"
+ snap_name="$OPTARG"
+ ;;
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
;;
s)
sizeonly="--size-only"
@@ -81,58 +85,69 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
-MASTER_ROOT=/var/opt/resin3/${masterPort}
-
-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} ]]
+if [[ -z ${master_host} ]]
then
echo "name of master server missing in $confFile or command line."
echo "$USAGE"
exit 1
fi
-if [[ -z ${masterPort} ]]
+if [[ -z ${rsyncd_port} ]]
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"
exit 1
-
fi
-rsyncd_port=`expr 10000 + ${masterPort}`
-logMessage started by $oldwhoami
-logMessage command: $0 $originalargs
+if [[ -z ${master_data_dir} ]]
+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"`
-if [[ ! -f ${prog}-enabled ]]
+logMessage started by $oldwhoami
+logMessage command: $0 $@
+
+if [[ ! -f ${solr_root}/logs/snappuller-enabled ]]
then
logMessage snappuller disabled
exit 1
@@ -140,55 +155,61 @@ fi
# make sure we can ssh to master
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
- logMessage failed to ssh to master ${masterHost}
+ logMessage failed to ssh to master ${master_host}
exit 1
fi
# get directory name of latest snapshot if not specified on command line
-if [[ -z ${name} ]]
+if [[ -z ${snap_name} ]]
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
# 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
- logMessage no new snapshot available on ${masterHost}:${masterPort}
+ logMessage no new snapshot available on ${master_host} in ${master_data_dir}
logExit ended 0
fi
# 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
# 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
if [[ -n ${sizeonly} ]]
then
- rm -f ${name}-wip/segments
- rm -f ${name}-wip/*.del
+ rm -f ${data_dir}/${name}-wip/segments
+ rm -f ${data_dir}/${name}-wip/*.del
fi
logMessage pulling snapshot ${name}
# 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
rsyncStart=`date`
startTimestamp=`date -d "$rsyncStart" +'%Y%m%d-%H%M%S'`
rsyncStartSec=`date -d "$rsyncStart" +'%s'`
startStatus="rsync of `basename ${name}` started:$startTimestamp"
-echo ${startStatus} > logs/snappuller.status
-# push stats/state to master
-scp -q -o StrictHostKeyChecking=no logs/snappuller.status ${masterHost}:${MASTER_ROOT}/logs/clients/snapshot.status.`uname -n`
+echo ${startStatus} > ${solr_root}/logs/snappuller.status
+pushStatus
# rsync over files that have changed
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=$?
rsyncEnd=`date`
@@ -198,15 +219,16 @@ elapsed=`expr $rsyncEndSec - $rsyncStartSec`
if [[ $rc != 0 ]]
then
logMessage rsync failed
- /bin/rm -rf ${name}-wip
- echo ${startStatus} failed:$endTimestamp > logs/snappuller.status
+ /bin/rm -rf ${data_dir}/${name}-wip
+ echo ${startStatus} failed:$endTimestamp > ${solr_root}/logs/snappuller.status
+ pushStatus
logExit failed 1
fi
# move into place atomically
-mv ${name}-wip ${name}
+mv ${data_dir}/${name}-wip ${data_dir}/${name}
# 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
diff --git a/src/scripts/snappuller-disable b/src/scripts/snappuller-disable
index eb4b1bb2849..aac98e66ee3 100755
--- a/src/scripts/snappuller-disable
+++ b/src/scripts/snappuller-disable
@@ -1,44 +1,47 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snappuller-disable.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/snappuller.log
+log=${solr_root}/logs/snappuller.log
# define usage string
USAGE="\
-usage: $prog [ -v ]
+usage: $prog [-u username] [-v]
+ -u specify user to sudo to before running script
-v increase verbosity
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts u:v OPTION
do
case $OPTION in
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -47,36 +50,14 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
+
+fixUser "$@"
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 command: $0 $originalargs
-name=snappuller-enabled
+logMessage command: $0 $@
+name=${solr_root}/logs/snappuller-enabled
if [[ -f ${name} ]]
then
diff --git a/src/scripts/snappuller-enable b/src/scripts/snappuller-enable
index 71643a5d842..9969f2763fc 100755
--- a/src/scripts/snappuller-enable
+++ b/src/scripts/snappuller-enable
@@ -1,44 +1,47 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snappuller-enable.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/snappuller.log
+log=${solr_root}/logs/snappuller.log
# define usage string
USAGE="\
-usage: $prog [ -v ]
+usage: $prog [-u username] [-v]
+ -u specify user to sudo to before running script
-v increase verbosity
"
-unset verbose
-
# parse args
-originalargs="$@"
-while getopts v OPTION
+while getopts u:v OPTION
do
case $OPTION in
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -47,36 +50,14 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
+
+fixUser "$@"
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 command: $0 $originalargs
-name=snappuller-enabled
+logMessage command: $0 $@
+name=${solr_root}/logs/snappuller-enabled
if [[ -f ${name} ]]
then
diff --git a/src/scripts/snapshooter b/src/scripts/snapshooter
index 047d6f4cb11..1042c058192 100755
--- a/src/scripts/snapshooter
+++ b/src/scripts/snapshooter
@@ -1,64 +1,51 @@
#!/bin/bash
#
-# $Id$
-# $Source: /cvs/main/searching/solr-tools/snapshooter.template,v $
-# $Name: r20050725_standardized_server_enabled $
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# Shell script to 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
-if [[ $(whoami) != app ]]
-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
+unset data_dir user verbose
+. ${solr_root}/bin/scripts-util
# set up variables
prog=${0##*/}
-log=logs/${prog}.log
+log=${solr_root}/logs/${prog}.log
# define usage string
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
"
-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
-originalargs="$@"
-while getopts v OPTION
+while getopts d:u:v OPTION
do
case $OPTION in
+ d)
+ data_dir="$OPTARG"
+ ;;
+ u)
+ user="$OPTARG"
+ ;;
v)
verbose="v"
;;
@@ -67,36 +54,27 @@ do
exit 1
esac
done
-shift $(( OPTIND - 1 ))
-function timeStamp
-{
- date +'%Y%m%d-%H%M%S'
-}
+fixUser "$@"
-function logMessage
-{
- echo $(timeStamp) $@>>$log
- if [[ -n ${verbose} ]]
- then
- echo $@
- 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
-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"`
-name=snapshot.`date +"%Y%m%d%H%M%S"`
-temp=temp-${name}
+logMessage started by $oldwhoami
+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} ]]
then
@@ -117,7 +95,7 @@ logMessage taking snapshot ${name}
# take a snapshot using hard links into temporary location
# then move it into place atomically
-cp -lr index ${temp}
+cp -lr ${data_dir}/index ${temp}
mv ${temp} ${name}
logExit ended 0