@@ -, +, @@ $ sudo koha-shell -c ' /home/mason/git/koha/master/misc/migration_tools/rebuild_zebra.pl -b -v -z' koha1 | grep 'export directory' the export directory /tmp/jp1d1RmCzL has been deleted. $ sudo koha-shell -c ' /home/mason/git/koha/master/misc/migration_tools/rebuild_zebra.pl -b -v -z --tempdir /tmp1/aa1' koha1 | grep 'export directory' the export directory /tmp1/aa1/FEOKJIzPcA has been deleted. $ sudo koha-shell -c ' /home/mason/git/koha/master/misc/migration_tools/rebuild_zebra.pl -b -v -z --tempdir /tmp1/aa1 -d bb1' koha1 | grep 'export directory' the export directory /tmp1/aa1/bb1 has been deleted. --- misc/migration_tools/rebuild_zebra.pl | 43 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) --- a/misc/migration_tools/rebuild_zebra.pl +++ a/misc/migration_tools/rebuild_zebra.pl @@ -27,9 +27,12 @@ chdir $ENV{HOME} if (!(-r '.')); my $daemon_mode; my $daemon_sleep = 5; my $directory; +my $tempdir ; my $nosanitize; my $skip_export; my $keep_export; + + my $skip_index; my $reset; my $biblios; @@ -55,6 +58,7 @@ my $result = GetOptions( 'daemon' => \$daemon_mode, 'sleep:i' => \$daemon_sleep, 'd:s' => \$directory, + 'td|tempdir:s' => \$tempdir, 'r|reset' => \$reset, 's' => \$skip_export, 'k' => \$keep_export, @@ -144,7 +148,13 @@ if ($verbose_logging >= 2) { my $use_tempdir = 0; unless ($directory) { $use_tempdir = 1; - $directory = tempdir(CLEANUP => ($keep_export ? 0 : 1)); + $directory = tempdir( + CLEANUP => ( $keep_export ? 0 : 1 ), + DIR => ( $tempdir ? $tempdir : undef ), + ); +} +else { + $directory = "$tempdir/$directory" if $tempdir; } @@ -237,25 +247,33 @@ if ( $verbose_logging ) { print "CLEANING\n"; print "====================\n"; } + if ($keep_export) { - print "NOTHING cleaned : the export $directory has been kept.\n"; + print "NOTHING cleaned : the export directory $directory has been kept.\n"; print "You can re-run this script with the -s "; if ($use_tempdir) { print " and -d $directory parameters"; - } else { - print "parameter"; + } + else { + print " parameter"; } print "\n"; print "if you just want to rebuild zebra after changing the record.abs\n"; print "or another zebra config file\n"; -} else { + +} +else { + # if we're using a random temporary directory + # created by File::Temp, it will be removed + # automatically. so we do nothing here... + unless ($use_tempdir) { - # if we're using a temporary directory - # created by File::Temp, it will be removed - # automatically. - rmtree($directory, 0, 1); - print "directory $directory deleted\n"; + + # but if $use_tempdir, we remove it manually + rmtree( $directory, 0, 1 ); } + print "the export directory $directory has been deleted.\n" + if $verbose_logging; } sub do_one_pass { @@ -865,6 +883,11 @@ Parameters: -r clear Zebra index before adding records to index. Implies -w. + --tempdir Add a base directory for indexing. + Note: Using this arg in conjuction with the -d arg, will create + a directory under the path given with --tempdir + so, --tempdir /mnt/100_gig -d koha1, creates an absolute path of /mnt/100_gig/koha1 + -d Temporary directory for indexing. If not specified, one is automatically created. The export directory --