4 #use warnings; FIXME - Bug 2505
8 use File::Temp qw/ tempdir /;
11 use C4::AuthoritiesMarc;
14 # script that checks zebradir structure & create directories & mandatory files if needed
18 $|=1; # flushes output
19 # If the cron job starts us in an unreadable dir, we will break without
21 chdir $ENV{HOME} if (!(-r '.'));
34 my $process_zebraqueue;
35 my $do_not_clear_zebraqueue;
37 my $zebraidx_log_opt = " -v none,fatal,warn ";
38 my $result = GetOptions(
43 'nosanitize' => \$nosanitize,
47 'munge-config' => \$do_munge,
49 'h|help' => \$want_help,
51 'y' => \$do_not_clear_zebraqueue,
52 'z' => \$process_zebraqueue,
53 'v' => \$verbose_logging,
57 if (not $result or $want_help) {
62 if (not $biblios and not $authorities) {
63 my $msg = "Must specify -b or -a to reindex bibs or authorities\n";
64 $msg .= "Please do '$0 --help' to see usage.\n";
68 if ($authorities and $as_xml) {
69 my $msg = "Cannot specify both -a and -x\n";
70 $msg .= "Please do '$0 --help' to see usage.\n";
74 if ( !$as_xml and $nosanitize ) {
75 my $msg = "Cannot specify both -no_xml and -nosanitize\n";
76 $msg .= "Please do '$0 --help' to see usage.\n";
80 if ($process_zebraqueue and ($skip_export or $reset)) {
81 my $msg = "Cannot specify -r or -s if -z is specified\n";
82 $msg .= "Please do '$0 --help' to see usage.\n";
86 if ($process_zebraqueue and $do_not_clear_zebraqueue) {
87 my $msg = "Cannot specify both -y and -z\n";
88 $msg .= "Please do '$0 --help' to see usage.\n";
96 # -v is for verbose, which seems backwards here because of how logging is set
97 # on the CLI of zebraidx. It works this way. The default is to not log much
98 if ($verbose_logging) {
99 $zebraidx_log_opt = '';
103 unless ($directory) {
105 $directory = tempdir(CLEANUP => ($keep_export ? 0 : 1));
109 my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory};
110 my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
112 my $kohadir = C4::Context->config('intranetdir');
113 my $dbh = C4::Context->dbh;
114 my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
115 my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
117 if ( $verbose_logging ) {
118 print "Zebra configuration information\n";
119 print "================================\n";
120 print "Zebra biblio directory = $biblioserverdir\n";
121 print "Zebra authorities directory = $authorityserverdir\n";
122 print "Koha directory = $kohadir\n";
123 print "BIBLIONUMBER in : $biblionumbertagfield\$$biblionumbertagsubfield\n";
124 print "BIBLIOITEMNUMBER in : $biblioitemnumbertagfield\$$biblioitemnumbertagsubfield\n";
125 print "================================\n";
133 index_records('authority', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir);
135 print "skipping authorities\n" if ( $verbose_logging );
139 index_records('biblio', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir);
141 print "skipping biblios\n" if ( $verbose_logging );
145 if ( $verbose_logging ) {
146 print "====================\n";
148 print "====================\n";
151 print "NOTHING cleaned : the export $directory has been kept.\n";
152 print "You can re-run this script with the -s ";
154 print " and -d $directory parameters";
159 print "if you just want to rebuild zebra after changing the record.abs\n";
160 print "or another zebra config file\n";
162 unless ($use_tempdir) {
163 # if we're using a temporary directory
164 # created by File::Temp, it will be removed
166 rmtree($directory, 0, 1);
167 print "directory $directory deleted\n";
171 # This checks to see if the zebra directories exist under the provided path.
172 # If they don't, then zebra is likely to spit the dummy. This returns true
173 # if the directories had to be created, false otherwise.
174 sub check_zebra_dirs {
175 my ($base) = shift() . '/';
176 my $needed_repairing = 0;
177 my @dirs = ( '', 'key', 'register', 'shadow' );
178 foreach my $dir (@dirs) {
179 my $bdir = $base . $dir;
181 $needed_repairing = 1;
182 mkdir $bdir || die "Unable to create '$bdir': $!\n";
183 print "$0: needed to create '$bdir'\n";
186 return $needed_repairing;
187 } # ---------- end of subroutine check_zebra_dirs ----------
190 my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_;
192 my $num_records_exported = 0;
193 my $num_records_deleted = 0;
194 my $need_reset = check_zebra_dirs($server_dir);
196 print "$0: found broken zebra server directories: forcing a rebuild\n";
199 if ($skip_export && $verbose_logging) {
200 print "====================\n";
201 print "SKIPPING $record_type export\n";
202 print "====================\n";
204 if ( $verbose_logging ) {
205 print "====================\n";
206 print "exporting $record_type\n";
207 print "====================\n";
209 mkdir "$directory" unless (-d $directory);
210 mkdir "$directory/$record_type" unless (-d "$directory/$record_type");
211 if ($process_zebraqueue) {
212 my $entries = select_zebraqueue_records($record_type, 'deleted');
213 mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type");
214 $num_records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml);
215 mark_zebraqueue_batch_done($entries);
216 $entries = select_zebraqueue_records($record_type, 'updated');
217 mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type");
218 $num_records_exported = export_marc_records_from_list($record_type,
219 $entries, "$directory/upd_$record_type", $as_xml, $noxml);
220 mark_zebraqueue_batch_done($entries);
222 my $sth = select_all_records($record_type);
223 $num_records_exported = export_marc_records_from_sth($record_type, $sth, "$directory/$record_type", $as_xml, $noxml, $nosanitize);
224 unless ($do_not_clear_zebraqueue) {
225 mark_all_zebraqueue_done($record_type);
231 # and reindexing everything
233 if ( $verbose_logging ) {
234 print "====================\n";
235 print "REINDEXING zebra\n";
236 print "====================\n";
238 my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ;
239 if ($process_zebraqueue) {
240 do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
241 if $num_records_deleted;
242 do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
243 if $num_records_exported;
245 do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
246 if ($num_records_exported or $skip_export);
251 sub select_zebraqueue_records {
252 my ($record_type, $update_type) = @_;
254 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
255 my $op = ($update_type eq 'deleted') ? 'recordDelete' : 'specialUpdate';
257 my $sth = $dbh->prepare("SELECT id, biblio_auth_number
263 $sth->execute($server, $op);
264 my $entries = $sth->fetchall_arrayref({});
267 sub mark_all_zebraqueue_done {
268 my ($record_type) = @_;
270 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
272 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1
275 $sth->execute($server);
278 sub mark_zebraqueue_batch_done {
281 $dbh->{AutoCommit} = 0;
282 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1 WHERE id = ?");
284 foreach my $id (map { $_->{id} } @$entries) {
287 $dbh->{AutoCommit} = 1;
290 sub select_all_records {
291 my $record_type = shift;
292 return ($record_type eq 'biblio') ? select_all_biblios() : select_all_authorities();
295 sub select_all_authorities {
296 my $sth = $dbh->prepare("SELECT authid FROM auth_header");
301 sub select_all_biblios {
302 my $sth = $dbh->prepare("SELECT biblionumber FROM biblioitems ORDER BY biblionumber");
307 sub export_marc_records_from_sth {
308 my ($record_type, $sth, $directory, $as_xml, $noxml, $nosanitize) = @_;
310 my $num_exported = 0;
311 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
313 while (my ($record_number) = $sth->fetchrow_array) {
314 print "." if ( $verbose_logging );
315 print "\r$i" unless ($i++ %100 or !$verbose_logging);
317 my $marcxml = $record_type eq 'biblio'
318 ? GetXmlBiblio( $record_number )
319 : GetAuthorityXML( $record_number );
321 print OUT $marcxml if $marcxml;
326 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
328 # FIXME - when more than one record is exported and $as_xml is true,
329 # the output file is not valid XML - it's just multiple <record> elements
330 # strung together with no single root element. zebraidx doesn't seem
331 # to care, though, at least if you're using the GRS-1 filter. It does
332 # care if you're using the DOM filter, which requires valid XML file(s).
333 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
337 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
339 return $num_exported;
342 sub export_marc_records_from_list {
343 my ($record_type, $entries, $directory, $as_xml, $noxml) = @_;
345 my $num_exported = 0;
346 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
349 foreach my $record_number ( map { $_->{biblio_auth_number} }
350 grep { !$found{ $_->{biblio_auth_number} }++ }
352 print "." if ( $verbose_logging );
353 print "\r$i" unless ($i++ %100 or !$verbose_logging);
354 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
356 # FIXME - when more than one record is exported and $as_xml is true,
357 # the output file is not valid XML - it's just multiple <record> elements
358 # strung together with no single root element. zebraidx doesn't seem
359 # to care, though, at least if you're using the GRS-1 filter. It does
360 # care if you're using the DOM filter, which requires valid XML file(s).
361 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
365 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
367 return $num_exported;
370 sub generate_deleted_marc_records {
371 my ($record_type, $entries, $directory, $as_xml) = @_;
373 my $num_exported = 0;
374 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
376 foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
377 print "\r$i" unless ($i++ %100 or !$verbose_logging);
378 print "." if ( $verbose_logging );
380 my $marc = MARC::Record->new();
381 if ($record_type eq 'biblio') {
382 fix_biblio_ids($marc, $record_number, $record_number);
384 fix_authority_id($marc, $record_number);
386 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
387 fix_unimarc_100($marc);
390 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
393 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
395 return $num_exported;
400 sub get_corrected_marc_record {
401 my ($record_type, $record_number, $noxml) = @_;
403 my $marc = get_raw_marc_record($record_type, $record_number, $noxml);
407 if ($record_type eq 'biblio') {
408 my $succeeded = fix_biblio_ids($marc, $record_number);
409 return unless $succeeded;
411 fix_authority_id($marc, $record_number);
413 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
414 fix_unimarc_100($marc);
421 sub get_raw_marc_record {
422 my ($record_type, $record_number, $noxml) = @_;
425 if ($record_type eq 'biblio') {
427 my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?");
428 $fetch_sth->execute($record_number);
429 if (my ($blob) = $fetch_sth->fetchrow_array) {
430 $marc = MARC::Record->new_from_usmarc($blob);
431 $fetch_sth->finish();
433 return; # failure to find a bib is not a problem -
434 # a delete could have been done before
435 # trying to process a record update
438 eval { $marc = GetMarcBiblio($record_number); };
440 # here we do warn since catching an exception
441 # means that the bib was found but failed
443 warn "error retrieving biblio $record_number";
448 eval { $marc = GetAuthority($record_number); };
450 warn "error retrieving authority $record_number";
458 # FIXME - this routine is suspect
459 # It blanks the Leader/00-05 and Leader/12-16 to
460 # force them to be recalculated correct when
461 # the $marc->as_usmarc() or $marc->as_xml() is called.
462 # But why is this necessary? It would be a serious bug
463 # in MARC::Record (definitely) and MARC::File::XML (arguably)
464 # if they are emitting incorrect leader values.
467 my $leader = $marc->leader;
468 substr($leader, 0, 5) = ' ';
469 substr($leader, 10, 7) = '22 ';
470 $marc->leader(substr($leader, 0, 24));
474 # FIXME - it is essential to ensure that the biblionumber is present,
475 # otherwise, Zebra will choke on the record. However, this
476 # logic belongs in the relevant C4::Biblio APIs.
478 my $biblionumber = shift;
479 my $biblioitemnumber;
481 $biblioitemnumber = shift;
483 my $sth = $dbh->prepare(
484 "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
485 $sth->execute($biblionumber);
486 ($biblioitemnumber) = $sth->fetchrow_array;
488 unless ($biblioitemnumber) {
489 warn "failed to get biblioitemnumber for biblio $biblionumber";
494 # FIXME - this is cheating on two levels
495 # 1. C4::Biblio::_koha_marc_update_bib_ids is meant to be an internal function
496 # 2. Making sure that the biblionumber and biblioitemnumber are correct and
497 # present in the MARC::Record object ought to be part of GetMarcBiblio.
499 # On the other hand, this better for now than what rebuild_zebra.pl used to
500 # do, which was duplicate the code for inserting the biblionumber
501 # and biblioitemnumber
502 C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber);
507 sub fix_authority_id {
508 # FIXME - as with fix_biblio_ids, the authid must be present
509 # for Zebra's sake. However, this really belongs
510 # in C4::AuthoritiesMarc.
511 my ($marc, $authid) = @_;
512 unless ($marc->field('001') and $marc->field('001')->data() eq $authid){
513 $marc->delete_field($marc->field('001'));
514 $marc->insert_fields_ordered(MARC::Field->new('001',$authid));
518 sub fix_unimarc_100 {
519 # FIXME - again, if this is necessary, it belongs in C4::AuthoritiesMarc.
523 if ( length($marc->subfield( 100, "a" )) == 35 ) {
524 $string = $marc->subfield( 100, "a" );
525 my $f100 = $marc->field(100);
526 $marc->delete_field($f100);
529 $string = POSIX::strftime( "%Y%m%d", localtime );
531 $string = sprintf( "%-*s", 35, $string );
533 substr( $string, 22, 6, "frey50" );
534 unless ( length($marc->subfield( 100, "a" )) == 35 ) {
535 $marc->delete_field($marc->field(100));
536 $marc->insert_grouped_field(MARC::Field->new( 100, "", "", "a" => $string ));
541 my ($record_type, $op, $record_dir, $reset_index, $noshadow, $record_format, $zebraidx_log_opt) = @_;
543 my $zebra_server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
544 my $zebra_db_name = ($record_type eq 'biblio') ? 'biblios' : 'authorities';
545 my $zebra_config = C4::Context->zebraconfig($zebra_server)->{'config'};
546 my $zebra_db_dir = C4::Context->zebraconfig($zebra_server)->{'directory'};
548 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name init") if $reset_index;
549 system("zebraidx -c $zebra_config $zebraidx_log_opt $noshadow -g $record_format -d $zebra_db_name $op $record_dir");
550 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name commit") unless $noshadow;
556 $0: reindex MARC bibs and/or authorities in Zebra.
558 Use this batch job to reindex all biblio or authority
559 records in your Koha database. This job is useful
560 only if you are using Zebra; if you are using the 'NoZebra'
561 mode, this job should not be used.
564 -b index bibliographic records
566 -a index authority records
568 -z select only updated and deleted
569 records marked in the zebraqueue
570 table. Cannot be used with -r
573 -r clear Zebra index before
574 adding records to index
576 -d Temporary directory for indexing.
577 If not specified, one is automatically
578 created. The export directory
579 is automatically deleted unless
580 you supply the -k switch.
582 -k Do not delete export directory.
584 -s Skip export. Used if you have
585 already exported the records
588 -noxml index from ISO MARC blob
589 instead of MARC XML. This
590 option is recommended only
593 -x export and index as xml instead of is02709 (biblios only).
594 use this if you might have records > 99,999 chars,
596 -nosanitize export biblio/authority records directly from DB marcxml
597 field without sanitizing records. It speed up
598 dump process but could fail if DB contains badly
599 encoded records. Works only with -x,
601 -w skip shadow indexing for this batch
603 -y do NOT clear zebraqueue after indexing; normally,
604 after doing batch indexing, zebraqueue should be
605 marked done for the affected record type(s) so that
606 a running zebraqueue_daemon doesn't try to reindex
607 the same records - specify -y to override this.
608 Cannot be used with -z.
610 -v increase the amount of logging. Normally only
611 warnings and errors from the indexing are shown.
613 -munge-config Deprecated option to try
614 to fix Zebra config files.
615 --help or -h show this message.
619 # FIXME: the following routines are deprecated and
620 # will be removed once it is determined whether
621 # a script to fix Zebra configuration files is
625 # creating zebra-biblios.cfg depending on system
628 # getting zebraidx directory
630 foreach (qw(/usr/local/bin/zebraidx
639 unless ($zebraidxdir) {
641 ERROR: could not find zebraidx directory
642 ERROR: Either zebra is not installed,
643 ERROR: or it's in a directory I don't checked.
644 ERROR: do a which zebraidx and edit this file to add the result you get
648 $zebraidxdir =~ s/\/bin\/.*//;
649 print "Info : zebra is in $zebraidxdir \n";
651 # getting modules directory
653 foreach (qw(/usr/local/lib/idzebra-2.0/modules/mod-grs-xml.so
654 /usr/local/lib/idzebra/modules/mod-grs-xml.so
655 /usr/lib/idzebra/modules/mod-grs-xml.so
656 /usr/lib/idzebra-2.0/modules/mod-grs-xml.so
663 unless ($modulesdir) {
665 ERROR: could not find mod-grs-xml.so directory
666 ERROR: Either zebra is not properly compiled (libxml2 is not setup and you don t have mod-grs-xml.so,
667 ERROR: or it's in a directory I don't checked.
668 ERROR: find where mod-grs-xml.so is and edit this file to add the result you get
672 $modulesdir =~ s/\/modules\/.*//;
673 print "Info: zebra modules dir : $modulesdir\n";
675 # getting tab directory
677 foreach (qw(/usr/local/share/idzebra/tab/explain.att
678 /usr/local/share/idzebra-2.0/tab/explain.att
679 /usr/share/idzebra/tab/explain.att
680 /usr/share/idzebra-2.0/tab/explain.att
689 ERROR: could not find explain.att directory
690 ERROR: Either zebra is not properly compiled,
691 ERROR: or it's in a directory I don't checked.
692 ERROR: find where explain.att is and edit this file to add the result you get
696 $tabdir =~ s/\/tab\/.*//;
697 print "Info: tab dir : $tabdir\n";
700 # AUTHORITIES creating directory structure
702 my $created_dir_or_file = 0;
704 if ( $verbose_logging ) {
705 print "====================\n";
706 print "checking directories & files for authorities\n";
707 print "====================\n";
709 unless (-d "$authorityserverdir") {
710 system("mkdir -p $authorityserverdir");
711 print "Info: created $authorityserverdir\n";
712 $created_dir_or_file++;
714 unless (-d "$authorityserverdir/lock") {
715 mkdir "$authorityserverdir/lock";
716 print "Info: created $authorityserverdir/lock\n";
717 $created_dir_or_file++;
719 unless (-d "$authorityserverdir/register") {
720 mkdir "$authorityserverdir/register";
721 print "Info: created $authorityserverdir/register\n";
722 $created_dir_or_file++;
724 unless (-d "$authorityserverdir/shadow") {
725 mkdir "$authorityserverdir/shadow";
726 print "Info: created $authorityserverdir/shadow\n";
727 $created_dir_or_file++;
729 unless (-d "$authorityserverdir/tab") {
730 mkdir "$authorityserverdir/tab";
731 print "Info: created $authorityserverdir/tab\n";
732 $created_dir_or_file++;
734 unless (-d "$authorityserverdir/key") {
735 mkdir "$authorityserverdir/key";
736 print "Info: created $authorityserverdir/key\n";
737 $created_dir_or_file++;
740 unless (-d "$authorityserverdir/etc") {
741 mkdir "$authorityserverdir/etc";
742 print "Info: created $authorityserverdir/etc\n";
743 $created_dir_or_file++;
747 # AUTHORITIES : copying mandatory files
749 # the record model, depending on marc flavour
750 unless (-f "$authorityserverdir/tab/record.abs") {
751 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
752 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/authorities/record.abs $authorityserverdir/tab/record.abs");
753 print "Info: copied record.abs for UNIMARC\n";
755 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/authorities/record.abs $authorityserverdir/tab/record.abs");
756 print "Info: copied record.abs for USMARC\n";
758 $created_dir_or_file++;
760 unless (-f "$authorityserverdir/tab/sort-string-utf.chr") {
761 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/sort-string-utf.chr");
762 print "Info: copied sort-string-utf.chr\n";
763 $created_dir_or_file++;
765 unless (-f "$authorityserverdir/tab/word-phrase-utf.chr") {
766 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/word-phrase-utf.chr");
767 print "Info: copied word-phase-utf.chr\n";
768 $created_dir_or_file++;
770 unless (-f "$authorityserverdir/tab/auth1.att") {
771 system("cp -f $kohadir/etc/zebradb/authorities/etc/bib1.att $authorityserverdir/tab/auth1.att");
772 print "Info: copied auth1.att\n";
773 $created_dir_or_file++;
775 unless (-f "$authorityserverdir/tab/default.idx") {
776 system("cp -f $kohadir/etc/zebradb/etc/default.idx $authorityserverdir/tab/default.idx");
777 print "Info: copied default.idx\n";
778 $created_dir_or_file++;
781 unless (-f "$authorityserverdir/etc/ccl.properties") {
782 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
783 system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties");
784 print "Info: copied ccl.properties\n";
785 $created_dir_or_file++;
787 unless (-f "$authorityserverdir/etc/pqf.properties") {
788 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
789 system("cp -f $kohadir/etc/zebradb/pqf.properties $authorityserverdir/etc/pqf.properties");
790 print "Info: copied pqf.properties\n";
791 $created_dir_or_file++;
795 # AUTHORITIES : copying mandatory files
797 unless (-f C4::Context->zebraconfig('authorityserver')->{config}) {
798 open ZD,">:utf8 ",C4::Context->zebraconfig('authorityserver')->{config};
800 # generated by KOHA/misc/migration_tools/rebuild_zebra.pl
801 profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
804 # Files that describe the attribute sets supported.
809 modulePath:$modulesdir/modules/
810 # Specify record type
811 iso2709.recordType:grs.marcxml.record
813 recordId: (auth1,Local-Number)
819 lockDir: $authorityserverdir/lock
822 register: $authorityserverdir/register:4G
823 shadow: $authorityserverdir/shadow:4G
825 # Temp File area for result sets
826 setTmpDir: $authorityserverdir/tmp
828 # Temp File area for index program
829 keyTmpDir: $authorityserverdir/key
831 # Approx. Memory usage during indexing
835 print "Info: creating zebra-authorities.cfg\n";
836 $created_dir_or_file++;
839 if ($created_dir_or_file) {
840 print "Info: created : $created_dir_or_file directories & files\n";
842 print "Info: file & directories OK\n";
847 if ( $verbose_logging ) {
848 print "====================\n";
849 print "checking directories & files for biblios\n";
850 print "====================\n";
854 # BIBLIOS : creating directory structure
856 unless (-d "$biblioserverdir") {
857 system("mkdir -p $biblioserverdir");
858 print "Info: created $biblioserverdir\n";
859 $created_dir_or_file++;
861 unless (-d "$biblioserverdir/lock") {
862 mkdir "$biblioserverdir/lock";
863 print "Info: created $biblioserverdir/lock\n";
864 $created_dir_or_file++;
866 unless (-d "$biblioserverdir/register") {
867 mkdir "$biblioserverdir/register";
868 print "Info: created $biblioserverdir/register\n";
869 $created_dir_or_file++;
871 unless (-d "$biblioserverdir/shadow") {
872 mkdir "$biblioserverdir/shadow";
873 print "Info: created $biblioserverdir/shadow\n";
874 $created_dir_or_file++;
876 unless (-d "$biblioserverdir/tab") {
877 mkdir "$biblioserverdir/tab";
878 print "Info: created $biblioserverdir/tab\n";
879 $created_dir_or_file++;
881 unless (-d "$biblioserverdir/key") {
882 mkdir "$biblioserverdir/key";
883 print "Info: created $biblioserverdir/key\n";
884 $created_dir_or_file++;
886 unless (-d "$biblioserverdir/etc") {
887 mkdir "$biblioserverdir/etc";
888 print "Info: created $biblioserverdir/etc\n";
889 $created_dir_or_file++;
893 # BIBLIOS : copying mandatory files
895 # the record model, depending on marc flavour
896 unless (-f "$biblioserverdir/tab/record.abs") {
897 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
898 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/biblios/record.abs $biblioserverdir/tab/record.abs");
899 print "Info: copied record.abs for UNIMARC\n";
901 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/biblios/record.abs $biblioserverdir/tab/record.abs");
902 print "Info: copied record.abs for USMARC\n";
904 $created_dir_or_file++;
906 unless (-f "$biblioserverdir/tab/sort-string-utf.chr") {
907 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/sort-string-utf.chr");
908 print "Info: copied sort-string-utf.chr\n";
909 $created_dir_or_file++;
911 unless (-f "$biblioserverdir/tab/word-phrase-utf.chr") {
912 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/word-phrase-utf.chr");
913 print "Info: copied word-phase-utf.chr\n";
914 $created_dir_or_file++;
916 unless (-f "$biblioserverdir/tab/bib1.att") {
917 system("cp -f $kohadir/etc/zebradb/biblios/etc/bib1.att $biblioserverdir/tab/bib1.att");
918 print "Info: copied bib1.att\n";
919 $created_dir_or_file++;
921 unless (-f "$biblioserverdir/tab/default.idx") {
922 system("cp -f $kohadir/etc/zebradb/etc/default.idx $biblioserverdir/tab/default.idx");
923 print "Info: copied default.idx\n";
924 $created_dir_or_file++;
926 unless (-f "$biblioserverdir/etc/ccl.properties") {
927 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
928 system("cp -f $kohadir/etc/zebradb/ccl.properties $biblioserverdir/etc/ccl.properties");
929 print "Info: copied ccl.properties\n";
930 $created_dir_or_file++;
932 unless (-f "$biblioserverdir/etc/pqf.properties") {
933 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
934 system("cp -f $kohadir/etc/zebradb/pqf.properties $biblioserverdir/etc/pqf.properties");
935 print "Info: copied pqf.properties\n";
936 $created_dir_or_file++;
940 # BIBLIOS : copying mandatory files
942 unless (-f C4::Context->zebraconfig('biblioserver')->{config}) {
943 open ZD,">:utf8 ",C4::Context->zebraconfig('biblioserver')->{config};
945 # generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl
946 profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
949 # Files that describe the attribute sets supported.
954 modulePath:$modulesdir/modules/
955 # Specify record type
956 iso2709.recordType:grs.marcxml.record
958 recordId: (bib1,Local-Number)
964 lockDir: $biblioserverdir/lock
967 register: $biblioserverdir/register:4G
968 shadow: $biblioserverdir/shadow:4G
970 # Temp File area for result sets
971 setTmpDir: $biblioserverdir/tmp
973 # Temp File area for index program
974 keyTmpDir: $biblioserverdir/key
976 # Approx. Memory usage during indexing
980 print "Info: creating zebra-biblios.cfg\n";
981 $created_dir_or_file++;
984 if ($created_dir_or_file) {
985 print "Info: created : $created_dir_or_file directories & files\n";
987 print "Info: file & directories OK\n";