Skip to content

Apache Lucene open-source search software

avoid recursive find, test for maxdepth support, filter snapshot names on master: SOLR-207

Yonik Seeleydb21821167ec
diff --git a/CHANGES.txt b/CHANGES.txt
index eee42c69f5a..7cc16bd5a69 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -218,6 +218,11 @@ Bug Fixes
10. SOLR-198: RunExecutableListener always waited for the process to
finish, even when wait="false" was set. (Koji Sekiguchi via yonik)
+
+11. SOLR-207: Changed distribution scripts to remove recursive find
+ and avoid use of "find -maxdepth" on platforms where it is not
+ supported. (yonik)
+
Other Changes
1. Updated to Lucene 2.1
diff --git a/src/scripts/backupcleaner b/src/scripts/backupcleaner
index 2d82f901100..6c2ac7ca961 100755
--- a/src/scripts/backupcleaner
+++ b/src/scripts/backupcleaner
@@ -105,8 +105,16 @@ trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already oc
if [[ -n ${days} ]]
then
+ #is maxdepth supported?
+ find ${data_dir} -maxdepth 0 -name foobar >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ maxdepth="-maxdepth 1"
+ else
+ unset maxdepth
+ fi
+
logMessage cleaning up backups more than ${days} days old
- for i in `find ${data_dir} -name "backup.*" -maxdepth 1 -mtime +${days} -print`
+ for i in `find ${data_dir} ${maxdepth} -name 'backup.*' -mtime +${days} -print`
do
remove $i
done
diff --git a/src/scripts/snapcleaner b/src/scripts/snapcleaner
index e2903077a93..5301de3a772 100755
--- a/src/scripts/snapcleaner
+++ b/src/scripts/snapcleaner
@@ -111,8 +111,16 @@ trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already oc
if [[ -n ${days} ]]
then
+ #is maxdepth supported?
+ find ${data_dir} -maxdepth 0 -name foobar >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ maxdepth="-maxdepth 1"
+ else
+ unset maxdepth
+ fi
+
logMessage cleaning up snapshots more than ${days} days old
- for i in `find ${data_dir} -name "snapshot.*" -maxdepth 1 -mtime +${days} -print`
+ for i in `find ${data_dir} ${maxdepth} -name 'snapshot.*' -mtime +${days} -print`
do
remove $i
done
diff --git a/src/scripts/snapinstaller b/src/scripts/snapinstaller
index f15f2f872a8..f716e1a0b07 100755
--- a/src/scripts/snapinstaller
+++ b/src/scripts/snapinstaller
@@ -110,7 +110,7 @@ logMessage started by $oldwhoami
logMessage command: $0 $@
# get directory name of latest snapshot
-name=`find ${data_dir} -name snapshot.* -print|grep -v wip|sort -r|head -1`
+name=`ls ${data_dir}|grep 'snapshot\.'|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 ${data_dir"/index.tmp$$;logExit aborted 13' INT TERM
@@ -122,6 +122,8 @@ then
logExit ended 0
fi
+name=${data_dir}/${name}
+
# has snapshot already been installed
if [[ ${name} == `cat ${solr_root}/logs/snapshot.current 2>/dev/null` ]]
then
diff --git a/src/scripts/snappuller b/src/scripts/snappuller
index 2b8ae2c843b..7bab54dc60b 100755
--- a/src/scripts/snappuller
+++ b/src/scripts/snappuller
@@ -178,7 +178,7 @@ fi
# get directory name of latest snapshot if not specified on command line
if [[ -z ${snap_name} ]]
then
- snap_name=`ssh -o StrictHostKeyChecking=no ${master_host} "find ${master_data_dir} -name snapshot.\* -print"|grep -v wip|sort -r|head -1`
+ snap_name=`ssh -o StrictHostKeyChecking=no ${master_host} "ls ${master_data_dir}|grep 'snapshot\.'|grep -v wip|sort -r|head -1"`
fi
if [[ "${snap_name}" == "" ]]
then