4 #use warnings; FIXME - Bug 2505
8 use File::Temp qw/ tempdir /;
11 use C4::AuthoritiesMarc;
15 # script that checks zebradir structure & create directories & mandatory files if needed
19 $|=1; # flushes output
20 # If the cron job starts us in an unreadable dir, we will break without
22 chdir $ENV{HOME} if (!(-r '.'));
35 my $process_zebraqueue;
36 my $do_not_clear_zebraqueue;
40 my $verbose_logging = 0;
41 my $zebraidx_log_opt = " -v none,fatal,warn ";
42 my $result = GetOptions(
47 'nosanitize' => \$nosanitize,
51 'munge-config' => \$do_munge,
53 'h|help' => \$want_help,
55 'y' => \$do_not_clear_zebraqueue,
56 'z' => \$process_zebraqueue,
58 'length:i' => \$length,
59 'offset:i' => \$offset,
60 'v+' => \$verbose_logging,
64 if (not $result or $want_help) {
69 if (not $biblios and not $authorities) {
70 my $msg = "Must specify -b or -a to reindex bibs or authorities\n";
71 $msg .= "Please do '$0 --help' to see usage.\n";
75 if ( !$as_xml and $nosanitize ) {
76 my $msg = "Cannot specify both -no_xml and -nosanitize\n";
77 $msg .= "Please do '$0 --help' to see usage.\n";
81 if ($process_zebraqueue and ($skip_export or $reset)) {
82 my $msg = "Cannot specify -r or -s if -z is specified\n";
83 $msg .= "Please do '$0 --help' to see usage.\n";
87 if ($process_zebraqueue and $do_not_clear_zebraqueue) {
88 my $msg = "Cannot specify both -y and -z\n";
89 $msg .= "Please do '$0 --help' to see usage.\n";
97 # -v is for verbose, which seems backwards here because of how logging is set
98 # on the CLI of zebraidx. It works this way. The default is to not log much
99 if ($verbose_logging >= 2) {
100 $zebraidx_log_opt = '-v none,fatal,warn,all';
104 unless ($directory) {
106 $directory = tempdir(CLEANUP => ($keep_export ? 0 : 1));
110 my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory};
111 my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
113 my $kohadir = C4::Context->config('intranetdir');
114 my $bib_index_mode = C4::Context->config('zebra_bib_index_mode') || 'grs1';
115 my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') || 'dom';
117 my $dbh = C4::Context->dbh;
118 my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
119 my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
121 if ( $verbose_logging ) {
122 print "Zebra configuration information\n";
123 print "================================\n";
124 print "Zebra biblio directory = $biblioserverdir\n";
125 print "Zebra authorities directory = $authorityserverdir\n";
126 print "Koha directory = $kohadir\n";
127 print "BIBLIONUMBER in : $biblionumbertagfield\$$biblionumbertagsubfield\n";
128 print "BIBLIOITEMNUMBER in : $biblioitemnumbertagfield\$$biblioitemnumbertagsubfield\n";
129 print "================================\n";
137 index_records('authority', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir);
139 print "skipping authorities\n" if ( $verbose_logging );
143 index_records('biblio', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir);
145 print "skipping biblios\n" if ( $verbose_logging );
149 if ( $verbose_logging ) {
150 print "====================\n";
152 print "====================\n";
155 print "NOTHING cleaned : the export $directory has been kept.\n";
156 print "You can re-run this script with the -s ";
158 print " and -d $directory parameters";
163 print "if you just want to rebuild zebra after changing the record.abs\n";
164 print "or another zebra config file\n";
166 unless ($use_tempdir) {
167 # if we're using a temporary directory
168 # created by File::Temp, it will be removed
170 rmtree($directory, 0, 1);
171 print "directory $directory deleted\n";
175 # This checks to see if the zebra directories exist under the provided path.
176 # If they don't, then zebra is likely to spit the dummy. This returns true
177 # if the directories had to be created, false otherwise.
178 sub check_zebra_dirs {
179 my ($base) = shift() . '/';
180 my $needed_repairing = 0;
181 my @dirs = ( '', 'key', 'register', 'shadow', 'tmp' );
182 foreach my $dir (@dirs) {
183 my $bdir = $base . $dir;
185 $needed_repairing = 1;
186 mkdir $bdir || die "Unable to create '$bdir': $!\n";
187 print "$0: needed to create '$bdir'\n";
190 return $needed_repairing;
191 } # ---------- end of subroutine check_zebra_dirs ----------
194 my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_;
196 my $num_records_exported = 0;
198 my $need_reset = check_zebra_dirs($server_dir);
200 print "$0: found broken zebra server directories: forcing a rebuild\n";
203 if ($skip_export && $verbose_logging) {
204 print "====================\n";
205 print "SKIPPING $record_type export\n";
206 print "====================\n";
208 if ( $verbose_logging ) {
209 print "====================\n";
210 print "exporting $record_type\n";
211 print "====================\n";
213 mkdir "$directory" unless (-d $directory);
214 mkdir "$directory/$record_type" unless (-d "$directory/$record_type");
215 if ($process_zebraqueue) {
216 my $entries = select_zebraqueue_records($record_type, 'deleted');
217 mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type");
218 $records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml);
219 mark_zebraqueue_batch_done($entries);
220 $entries = select_zebraqueue_records($record_type, 'updated');
221 mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type");
222 $num_records_exported = export_marc_records_from_list($record_type,
223 $entries, "$directory/upd_$record_type", $as_xml, $noxml, $records_deleted);
224 mark_zebraqueue_batch_done($entries);
226 my $sth = select_all_records($record_type);
227 $num_records_exported = export_marc_records_from_sth($record_type, $sth, "$directory/$record_type", $as_xml, $noxml, $nosanitize);
228 unless ($do_not_clear_zebraqueue) {
229 mark_all_zebraqueue_done($record_type);
235 # and reindexing everything
237 if ( $verbose_logging ) {
238 print "====================\n";
239 print "REINDEXING zebra\n";
240 print "====================\n";
242 my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ;
243 if ($process_zebraqueue) {
244 do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
245 if %$records_deleted;
246 do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
247 if $num_records_exported;
249 do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
250 if ($num_records_exported or $skip_export);
255 sub select_zebraqueue_records {
256 my ($record_type, $update_type) = @_;
258 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
259 my $op = ($update_type eq 'deleted') ? 'recordDelete' : 'specialUpdate';
261 my $sth = $dbh->prepare("SELECT id, biblio_auth_number
267 $sth->execute($server, $op);
268 my $entries = $sth->fetchall_arrayref({});
271 sub mark_all_zebraqueue_done {
272 my ($record_type) = @_;
274 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
276 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1
279 $sth->execute($server);
282 sub mark_zebraqueue_batch_done {
285 $dbh->{AutoCommit} = 0;
286 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1 WHERE id = ?");
288 foreach my $id (map { $_->{id} } @$entries) {
291 $dbh->{AutoCommit} = 1;
294 sub select_all_records {
295 my $record_type = shift;
296 return ($record_type eq 'biblio') ? select_all_biblios() : select_all_authorities();
299 sub select_all_authorities {
300 my $strsth=qq{SELECT authid FROM auth_header};
301 $strsth.=qq{ WHERE $where } if ($where);
302 $strsth.=qq{ LIMIT $length } if ($length && !$offset);
303 $strsth.=qq{ LIMIT $offset,$length } if ($length && $offset);
304 my $sth = $dbh->prepare($strsth);
309 sub select_all_biblios {
310 my $strsth = qq{ SELECT biblionumber FROM biblioitems };
311 $strsth.=qq{ WHERE $where } if ($where);
312 $strsth.=qq{ LIMIT $length } if ($length && !$offset);
313 $strsth.=qq{ LIMIT $offset,$length } if ($offset);
314 my $sth = $dbh->prepare($strsth);
319 sub include_xml_wrapper {
321 my $record_type = shift;
323 return 0 unless $as_xml;
324 return 1 if $record_type eq 'biblio' and $bib_index_mode eq 'dom';
325 return 1 if $record_type eq 'authority' and $auth_index_mode eq 'dom';
330 sub export_marc_records_from_sth {
331 my ($record_type, $sth, $directory, $as_xml, $noxml, $nosanitize) = @_;
333 my $num_exported = 0;
334 open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
335 if (include_xml_wrapper($as_xml, $record_type)) {
336 # include XML declaration and root element
337 print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
340 my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
341 while (my ($record_number) = $sth->fetchrow_array) {
342 print "." if ( $verbose_logging );
343 print "\r$i" unless ($i++ %100 or !$verbose_logging);
345 my $marcxml = $record_type eq 'biblio'
346 ? GetXmlBiblio( $record_number )
347 : GetAuthorityXML( $record_number );
348 if ($record_type eq 'biblio'){
349 my @items = GetItemsInfo($record_number);
351 my $record = MARC::Record->new;
352 $record->encoding('UTF-8');
354 foreach my $item (@items){
355 my $record = Item2Marc($item, $record_number);
356 push @itemsrecord, $record->field($itemtag);
358 $record->insert_fields_ordered(@itemsrecord);
359 my $itemsxml = $record->as_xml_record();
361 substr($marcxml, 0, length($marcxml)-10) .
362 substr($itemsxml, index($itemsxml, "</leader>\n", 0) + 10);
366 print {$fh} $marcxml if $marcxml;
371 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
376 $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
377 $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
379 $rec = $marc->as_usmarc();
385 warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML");
389 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
390 print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
392 return $num_exported;
395 sub export_marc_records_from_list {
396 my ($record_type, $entries, $directory, $as_xml, $noxml, $records_deleted) = @_;
398 my $num_exported = 0;
399 open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
400 if (include_xml_wrapper($as_xml, $record_type)) {
401 # include XML declaration and root element
402 print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
406 # Skip any deleted records. We check for this anyway, but this reduces error spam
407 my %found = %$records_deleted;
408 foreach my $record_number ( map { $_->{biblio_auth_number} }
409 grep { !$found{ $_->{biblio_auth_number} }++ }
411 print "." if ( $verbose_logging );
412 print "\r$i" unless ($i++ %100 or !$verbose_logging);
413 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
418 $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
419 $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
421 $rec = $marc->as_usmarc();
427 warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML");
432 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
433 print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
435 return $num_exported;
438 sub generate_deleted_marc_records {
439 my ($record_type, $entries, $directory, $as_xml) = @_;
441 my $records_deleted = {};
442 open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
443 if (include_xml_wrapper($as_xml, $record_type)) {
444 # include XML declaration and root element
445 print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
448 foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
449 print "\r$i" unless ($i++ %100 or !$verbose_logging);
450 print "." if ( $verbose_logging );
452 my $marc = MARC::Record->new();
453 if ($record_type eq 'biblio') {
454 fix_biblio_ids($marc, $record_number, $record_number);
456 fix_authority_id($marc, $record_number);
458 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
459 fix_unimarc_100($marc);
464 $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
465 $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
467 $rec = $marc->as_usmarc();
471 $records_deleted->{$record_number} = 1;
473 print "\nRecords exported: $i\n" if ( $verbose_logging );
474 print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
476 return $records_deleted;
481 sub get_corrected_marc_record {
482 my ($record_type, $record_number, $noxml) = @_;
484 my $marc = get_raw_marc_record($record_type, $record_number, $noxml);
488 if ($record_type eq 'authority') {
489 fix_authority_id($marc, $record_number);
491 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
492 fix_unimarc_100($marc);
499 sub get_raw_marc_record {
500 my ($record_type, $record_number, $noxml) = @_;
503 if ($record_type eq 'biblio') {
505 my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?");
506 $fetch_sth->execute($record_number);
507 if (my ($blob) = $fetch_sth->fetchrow_array) {
508 $marc = MARC::Record->new_from_usmarc($blob);
510 warn "error creating MARC::Record from $blob";
513 # failure to find a bib is not a problem -
514 # a delete could have been done before
515 # trying to process a record update
517 $fetch_sth->finish();
520 eval { $marc = GetMarcBiblio($record_number, 1); };
522 # here we do warn since catching an exception
523 # means that the bib was found but failed
525 warn "error retrieving biblio $record_number";
530 eval { $marc = GetAuthority($record_number); };
532 warn "error retrieving authority $record_number";
540 # FIXME - this routine is suspect
541 # It blanks the Leader/00-05 and Leader/12-16 to
542 # force them to be recalculated correct when
543 # the $marc->as_usmarc() or $marc->as_xml() is called.
544 # But why is this necessary? It would be a serious bug
545 # in MARC::Record (definitely) and MARC::File::XML (arguably)
546 # if they are emitting incorrect leader values.
549 my $leader = $marc->leader;
550 substr($leader, 0, 5) = ' ';
551 substr($leader, 10, 7) = '22 ';
552 $marc->leader(substr($leader, 0, 24));
556 # FIXME - it is essential to ensure that the biblionumber is present,
557 # otherwise, Zebra will choke on the record. However, this
558 # logic belongs in the relevant C4::Biblio APIs.
560 my $biblionumber = shift;
561 my $biblioitemnumber;
563 $biblioitemnumber = shift;
565 my $sth = $dbh->prepare(
566 "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
567 $sth->execute($biblionumber);
568 ($biblioitemnumber) = $sth->fetchrow_array;
570 unless ($biblioitemnumber) {
571 warn "failed to get biblioitemnumber for biblio $biblionumber";
576 # FIXME - this is cheating on two levels
577 # 1. C4::Biblio::_koha_marc_update_bib_ids is meant to be an internal function
578 # 2. Making sure that the biblionumber and biblioitemnumber are correct and
579 # present in the MARC::Record object ought to be part of GetMarcBiblio.
581 # On the other hand, this better for now than what rebuild_zebra.pl used to
582 # do, which was duplicate the code for inserting the biblionumber
583 # and biblioitemnumber
584 C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber);
589 sub fix_authority_id {
590 # FIXME - as with fix_biblio_ids, the authid must be present
591 # for Zebra's sake. However, this really belongs
592 # in C4::AuthoritiesMarc.
593 my ($marc, $authid) = @_;
594 unless ($marc->field('001') and $marc->field('001')->data() eq $authid){
595 $marc->delete_field($marc->field('001'));
596 $marc->insert_fields_ordered(MARC::Field->new('001',$authid));
600 sub fix_unimarc_100 {
601 # FIXME - again, if this is necessary, it belongs in C4::AuthoritiesMarc.
605 if ( length($marc->subfield( 100, "a" )) == 36 ) {
606 $string = $marc->subfield( 100, "a" );
607 my $f100 = $marc->field(100);
608 $marc->delete_field($f100);
611 $string = POSIX::strftime( "%Y%m%d", localtime );
613 $string = sprintf( "%-*s", 35, $string );
615 substr( $string, 22, 6, "frey50" );
616 unless ( length($marc->subfield( 100, "a" )) == 36 ) {
617 $marc->delete_field($marc->field(100));
618 $marc->insert_grouped_field(MARC::Field->new( 100, "", "", "a" => $string ));
623 my ($record_type, $op, $record_dir, $reset_index, $noshadow, $record_format, $zebraidx_log_opt) = @_;
625 my $zebra_server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
626 my $zebra_db_name = ($record_type eq 'biblio') ? 'biblios' : 'authorities';
627 my $zebra_config = C4::Context->zebraconfig($zebra_server)->{'config'};
628 my $zebra_db_dir = C4::Context->zebraconfig($zebra_server)->{'directory'};
630 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name init") if $reset_index;
631 system("zebraidx -c $zebra_config $zebraidx_log_opt $noshadow -g $record_format -d $zebra_db_name $op $record_dir");
632 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name commit") unless $noshadow;
638 $0: reindex MARC bibs and/or authorities in Zebra.
640 Use this batch job to reindex all biblio or authority
641 records in your Koha database. This job is useful
642 only if you are using Zebra; if you are using the 'NoZebra'
643 mode, this job should not be used.
646 -b index bibliographic records
648 -a index authority records
650 -z select only updated and deleted
651 records marked in the zebraqueue
652 table. Cannot be used with -r
655 -r clear Zebra index before
656 adding records to index
658 -d Temporary directory for indexing.
659 If not specified, one is automatically
660 created. The export directory
661 is automatically deleted unless
662 you supply the -k switch.
664 -k Do not delete export directory.
666 -s Skip export. Used if you have
667 already exported the records
670 -noxml index from ISO MARC blob
671 instead of MARC XML. This
672 option is recommended only
675 -x export and index as xml instead of is02709 (biblios only).
676 use this if you might have records > 99,999 chars,
678 -nosanitize export biblio/authority records directly from DB marcxml
679 field without sanitizing records. It speed up
680 dump process but could fail if DB contains badly
681 encoded records. Works only with -x,
683 -w skip shadow indexing for this batch
685 -y do NOT clear zebraqueue after indexing; normally,
686 after doing batch indexing, zebraqueue should be
687 marked done for the affected record type(s) so that
688 a running zebraqueue_daemon doesn't try to reindex
689 the same records - specify -y to override this.
690 Cannot be used with -z.
692 -v increase the amount of logging. Normally only
693 warnings and errors from the indexing are shown.
694 Use log level 2 (-v -v) to include all Zebra logs.
696 --length 1234 how many biblio you want to export
697 --offset 1243 offset you want to start to
698 example: --offset 500 --length=500 will result in a LIMIT 500,1000 (exporting 1000 records, starting by the 500th one)
699 note that the numbers are NOT related to biblionumber, that's the intended behaviour.
700 --where let you specify a WHERE query, like itemtype='BOOK'
701 or something like that
703 --munge-config Deprecated option to try
704 to fix Zebra config files.
705 --help or -h show this message.
709 # FIXME: the following routines are deprecated and
710 # will be removed once it is determined whether
711 # a script to fix Zebra configuration files is
715 # creating zebra-biblios.cfg depending on system
718 # getting zebraidx directory
720 foreach (qw(/usr/local/bin/zebraidx
729 unless ($zebraidxdir) {
731 ERROR: could not find zebraidx directory
732 ERROR: Either zebra is not installed,
733 ERROR: or it's in a directory I don't checked.
734 ERROR: do a which zebraidx and edit this file to add the result you get
738 $zebraidxdir =~ s/\/bin\/.*//;
739 print "Info : zebra is in $zebraidxdir \n";
741 # getting modules directory
743 foreach (qw(/usr/local/lib/idzebra-2.0/modules/mod-grs-xml.so
744 /usr/local/lib/idzebra/modules/mod-grs-xml.so
745 /usr/lib/idzebra/modules/mod-grs-xml.so
746 /usr/lib/idzebra-2.0/modules/mod-grs-xml.so
753 unless ($modulesdir) {
755 ERROR: could not find mod-grs-xml.so directory
756 ERROR: Either zebra is not properly compiled (libxml2 is not setup and you don t have mod-grs-xml.so,
757 ERROR: or it's in a directory I don't checked.
758 ERROR: find where mod-grs-xml.so is and edit this file to add the result you get
762 $modulesdir =~ s/\/modules\/.*//;
763 print "Info: zebra modules dir : $modulesdir\n";
765 # getting tab directory
767 foreach (qw(/usr/local/share/idzebra/tab/explain.att
768 /usr/local/share/idzebra-2.0/tab/explain.att
769 /usr/share/idzebra/tab/explain.att
770 /usr/share/idzebra-2.0/tab/explain.att
779 ERROR: could not find explain.att directory
780 ERROR: Either zebra is not properly compiled,
781 ERROR: or it's in a directory I don't checked.
782 ERROR: find where explain.att is and edit this file to add the result you get
786 $tabdir =~ s/\/tab\/.*//;
787 print "Info: tab dir : $tabdir\n";
790 # AUTHORITIES creating directory structure
792 my $created_dir_or_file = 0;
794 if ( $verbose_logging ) {
795 print "====================\n";
796 print "checking directories & files for authorities\n";
797 print "====================\n";
799 unless (-d "$authorityserverdir") {
800 system("mkdir -p $authorityserverdir");
801 print "Info: created $authorityserverdir\n";
802 $created_dir_or_file++;
804 unless (-d "$authorityserverdir/lock") {
805 mkdir "$authorityserverdir/lock";
806 print "Info: created $authorityserverdir/lock\n";
807 $created_dir_or_file++;
809 unless (-d "$authorityserverdir/register") {
810 mkdir "$authorityserverdir/register";
811 print "Info: created $authorityserverdir/register\n";
812 $created_dir_or_file++;
814 unless (-d "$authorityserverdir/shadow") {
815 mkdir "$authorityserverdir/shadow";
816 print "Info: created $authorityserverdir/shadow\n";
817 $created_dir_or_file++;
819 unless (-d "$authorityserverdir/tab") {
820 mkdir "$authorityserverdir/tab";
821 print "Info: created $authorityserverdir/tab\n";
822 $created_dir_or_file++;
824 unless (-d "$authorityserverdir/key") {
825 mkdir "$authorityserverdir/key";
826 print "Info: created $authorityserverdir/key\n";
827 $created_dir_or_file++;
830 unless (-d "$authorityserverdir/etc") {
831 mkdir "$authorityserverdir/etc";
832 print "Info: created $authorityserverdir/etc\n";
833 $created_dir_or_file++;
837 # AUTHORITIES : copying mandatory files
839 # the record model, depending on marc flavour
840 unless (-f "$authorityserverdir/tab/record.abs") {
841 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
842 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/authorities/record.abs $authorityserverdir/tab/record.abs");
843 print "Info: copied record.abs for UNIMARC\n";
845 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/authorities/record.abs $authorityserverdir/tab/record.abs");
846 print "Info: copied record.abs for USMARC\n";
848 $created_dir_or_file++;
850 unless (-f "$authorityserverdir/tab/sort-string-utf.chr") {
851 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/sort-string-utf.chr");
852 print "Info: copied sort-string-utf.chr\n";
853 $created_dir_or_file++;
855 unless (-f "$authorityserverdir/tab/word-phrase-utf.chr") {
856 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/word-phrase-utf.chr");
857 print "Info: copied word-phase-utf.chr\n";
858 $created_dir_or_file++;
860 unless (-f "$authorityserverdir/tab/auth1.att") {
861 system("cp -f $kohadir/etc/zebradb/authorities/etc/bib1.att $authorityserverdir/tab/auth1.att");
862 print "Info: copied auth1.att\n";
863 $created_dir_or_file++;
865 unless (-f "$authorityserverdir/tab/default.idx") {
866 system("cp -f $kohadir/etc/zebradb/etc/default.idx $authorityserverdir/tab/default.idx");
867 print "Info: copied default.idx\n";
868 $created_dir_or_file++;
871 unless (-f "$authorityserverdir/etc/ccl.properties") {
872 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
873 system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties");
874 print "Info: copied ccl.properties\n";
875 $created_dir_or_file++;
877 unless (-f "$authorityserverdir/etc/pqf.properties") {
878 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
879 system("cp -f $kohadir/etc/zebradb/pqf.properties $authorityserverdir/etc/pqf.properties");
880 print "Info: copied pqf.properties\n";
881 $created_dir_or_file++;
885 # AUTHORITIES : copying mandatory files
887 unless (-f C4::Context->zebraconfig('authorityserver')->{config}) {
888 open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config};
890 # generated by KOHA/misc/migration_tools/rebuild_zebra.pl
891 profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
894 # Files that describe the attribute sets supported.
899 modulePath:$modulesdir/modules/
900 # Specify record type
901 iso2709.recordType:grs.marcxml.record
903 recordId: (auth1,Local-Number)
909 lockDir: $authorityserverdir/lock
912 register: $authorityserverdir/register:4G
913 shadow: $authorityserverdir/shadow:4G
915 # Temp File area for result sets
916 setTmpDir: $authorityserverdir/tmp
918 # Temp File area for index program
919 keyTmpDir: $authorityserverdir/key
921 # Approx. Memory usage during indexing
925 print "Info: creating zebra-authorities.cfg\n";
926 $created_dir_or_file++;
929 if ($created_dir_or_file) {
930 print "Info: created : $created_dir_or_file directories & files\n";
932 print "Info: file & directories OK\n";
937 if ( $verbose_logging ) {
938 print "====================\n";
939 print "checking directories & files for biblios\n";
940 print "====================\n";
944 # BIBLIOS : creating directory structure
946 unless (-d "$biblioserverdir") {
947 system("mkdir -p $biblioserverdir");
948 print "Info: created $biblioserverdir\n";
949 $created_dir_or_file++;
951 unless (-d "$biblioserverdir/lock") {
952 mkdir "$biblioserverdir/lock";
953 print "Info: created $biblioserverdir/lock\n";
954 $created_dir_or_file++;
956 unless (-d "$biblioserverdir/register") {
957 mkdir "$biblioserverdir/register";
958 print "Info: created $biblioserverdir/register\n";
959 $created_dir_or_file++;
961 unless (-d "$biblioserverdir/shadow") {
962 mkdir "$biblioserverdir/shadow";
963 print "Info: created $biblioserverdir/shadow\n";
964 $created_dir_or_file++;
966 unless (-d "$biblioserverdir/tab") {
967 mkdir "$biblioserverdir/tab";
968 print "Info: created $biblioserverdir/tab\n";
969 $created_dir_or_file++;
971 unless (-d "$biblioserverdir/key") {
972 mkdir "$biblioserverdir/key";
973 print "Info: created $biblioserverdir/key\n";
974 $created_dir_or_file++;
976 unless (-d "$biblioserverdir/etc") {
977 mkdir "$biblioserverdir/etc";
978 print "Info: created $biblioserverdir/etc\n";
979 $created_dir_or_file++;
983 # BIBLIOS : copying mandatory files
985 # the record model, depending on marc flavour
986 unless (-f "$biblioserverdir/tab/record.abs") {
987 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
988 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/biblios/record.abs $biblioserverdir/tab/record.abs");
989 print "Info: copied record.abs for UNIMARC\n";
991 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/biblios/record.abs $biblioserverdir/tab/record.abs");
992 print "Info: copied record.abs for USMARC\n";
994 $created_dir_or_file++;
996 unless (-f "$biblioserverdir/tab/sort-string-utf.chr") {
997 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/sort-string-utf.chr");
998 print "Info: copied sort-string-utf.chr\n";
999 $created_dir_or_file++;
1001 unless (-f "$biblioserverdir/tab/word-phrase-utf.chr") {
1002 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/word-phrase-utf.chr");
1003 print "Info: copied word-phase-utf.chr\n";
1004 $created_dir_or_file++;
1006 unless (-f "$biblioserverdir/tab/bib1.att") {
1007 system("cp -f $kohadir/etc/zebradb/biblios/etc/bib1.att $biblioserverdir/tab/bib1.att");
1008 print "Info: copied bib1.att\n";
1009 $created_dir_or_file++;
1011 unless (-f "$biblioserverdir/tab/default.idx") {
1012 system("cp -f $kohadir/etc/zebradb/etc/default.idx $biblioserverdir/tab/default.idx");
1013 print "Info: copied default.idx\n";
1014 $created_dir_or_file++;
1016 unless (-f "$biblioserverdir/etc/ccl.properties") {
1017 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
1018 system("cp -f $kohadir/etc/zebradb/ccl.properties $biblioserverdir/etc/ccl.properties");
1019 print "Info: copied ccl.properties\n";
1020 $created_dir_or_file++;
1022 unless (-f "$biblioserverdir/etc/pqf.properties") {
1023 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
1024 system("cp -f $kohadir/etc/zebradb/pqf.properties $biblioserverdir/etc/pqf.properties");
1025 print "Info: copied pqf.properties\n";
1026 $created_dir_or_file++;
1030 # BIBLIOS : copying mandatory files
1032 unless (-f C4::Context->zebraconfig('biblioserver')->{config}) {
1033 open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config};
1035 # generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl
1036 profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
1039 # Files that describe the attribute sets supported.
1044 modulePath:$modulesdir/modules/
1045 # Specify record type
1046 iso2709.recordType:grs.marcxml.record
1048 recordId: (bib1,Local-Number)
1054 lockDir: $biblioserverdir/lock
1057 register: $biblioserverdir/register:4G
1058 shadow: $biblioserverdir/shadow:4G
1060 # Temp File area for result sets
1061 setTmpDir: $biblioserverdir/tmp
1063 # Temp File area for index program
1064 keyTmpDir: $biblioserverdir/key
1066 # Approx. Memory usage during indexing
1070 print "Info: creating zebra-biblios.cfg\n";
1071 $created_dir_or_file++;
1074 if ($created_dir_or_file) {
1075 print "Info: created : $created_dir_or_file directories & files\n";
1077 print "Info: file & directories OK\n";