7 use File::Temp qw/ tempdir /;
10 use C4::AuthoritiesMarc;
13 # script that checks zebradir structure & create directories & mandatory files if needed
17 $|=1; # flushes output
30 my $process_zebraqueue;
31 my $do_not_clear_zebraqueue;
33 my $zebraidx_log_opt = " -v none,fatal,warn ";
34 my $result = GetOptions(
42 'munge-config' => \$do_munge,
44 'h|help' => \$want_help,
46 'y' => \$do_not_clear_zebraqueue,
47 'z' => \$process_zebraqueue,
48 'v' => \$verbose_logging,
52 if (not $result or $want_help) {
57 if (not $biblios and not $authorities) {
58 my $msg = "Must specify -b or -a to reindex bibs or authorities\n";
59 $msg .= "Please do '$0 --help' to see usage.\n";
63 if ($authorities and $as_xml) {
64 my $msg = "Cannot specify both -a and -x\n";
65 $msg .= "Please do '$0 --help' to see usage.\n";
69 if ($process_zebraqueue and ($skip_export or $reset)) {
70 my $msg = "Cannot specify -r or -s if -z is specified\n";
71 $msg .= "Please do '$0 --help' to see usage.\n";
75 if ($process_zebraqueue and $do_not_clear_zebraqueue) {
76 my $msg = "Cannot specify both -y and -z\n";
77 $msg .= "Please do '$0 --help' to see usage.\n";
85 # -v is for verbose, which seems backwards here because of how logging is set
86 # on the CLI of zebraidx. It works this way. The default is to not log much
87 if ($verbose_logging) {
88 $zebraidx_log_opt = '';
94 $directory = tempdir(CLEANUP => ($keep_export ? 0 : 1));
98 my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory};
99 my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
101 my $kohadir = C4::Context->config('intranetdir');
102 my $dbh = C4::Context->dbh;
103 my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
104 my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
106 if ( $verbose_logging ) {
107 print "Zebra configuration information\n";
108 print "================================\n";
109 print "Zebra biblio directory = $biblioserverdir\n";
110 print "Zebra authorities directory = $authorityserverdir\n";
111 print "Koha directory = $kohadir\n";
112 print "BIBLIONUMBER in : $biblionumbertagfield\$$biblionumbertagsubfield\n";
113 print "BIBLIOITEMNUMBER in : $biblioitemnumbertagfield\$$biblioitemnumbertagsubfield\n";
114 print "================================\n";
122 index_records('authority', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt);
124 print "skipping authorities\n";
128 index_records('biblio', $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt);
130 print "skipping biblios\n";
134 if ( $verbose_logging ) {
135 print "====================\n";
137 print "====================\n";
140 print "NOTHING cleaned : the export $directory has been kept.\n";
141 print "You can re-run this script with the -s ";
143 print " and -d $directory parameters";
148 print "if you just want to rebuild zebra after changing the record.abs\n";
149 print "or another zebra config file\n";
151 unless ($use_tempdir) {
152 # if we're using a temporary directory
153 # created by File::Temp, it will be removed
155 rmtree($directory, 0, 1);
156 print "directory $directory deleted\n";
161 my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt) = @_;
163 my $num_records_exported = 0;
164 my $num_records_deleted = 0;
165 if ($skip_export && $verbose_logging) {
166 print "====================\n";
167 print "SKIPPING $record_type export\n";
168 print "====================\n";
170 if ( $verbose_logging ) {
171 print "====================\n";
172 print "exporting $record_type\n";
173 print "====================\n";
175 mkdir "$directory" unless (-d $directory);
176 mkdir "$directory/$record_type" unless (-d "$directory/$record_type");
177 if ($process_zebraqueue) {
178 my $entries = select_zebraqueue_records($record_type, 'deleted');
179 mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type");
180 $num_records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml);
181 mark_zebraqueue_batch_done($entries);
182 $entries = select_zebraqueue_records($record_type, 'updated');
183 mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type");
184 $num_records_exported = export_marc_records_from_list($record_type,
185 $entries, "$directory/upd_$record_type", $as_xml, $noxml);
186 mark_zebraqueue_batch_done($entries);
188 my $sth = select_all_records($record_type);
189 $num_records_exported = export_marc_records_from_sth($record_type, $sth, "$directory/$record_type", $as_xml, $noxml);
190 unless ($do_not_clear_zebraqueue) {
191 mark_all_zebraqueue_done($record_type);
197 # and reindexing everything
199 if ( $verbose_logging ) {
200 print "====================\n";
201 print "REINDEXING zebra\n";
202 print "====================\n";
204 my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ;
205 if ($process_zebraqueue) {
206 do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
207 if $num_records_deleted;
208 do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
209 if $num_records_exported;
211 do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
212 if $num_records_exported;
216 sub select_zebraqueue_records {
217 my ($record_type, $update_type) = @_;
219 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
220 my $op = ($update_type eq 'deleted') ? 'recordDelete' : 'specialUpdate';
222 my $sth = $dbh->prepare("SELECT id, biblio_auth_number
228 $sth->execute($server, $op);
229 my $entries = $sth->fetchall_arrayref({});
232 sub mark_all_zebraqueue_done {
233 my ($record_type) = @_;
235 my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
237 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1
240 $sth->execute($server);
243 sub mark_zebraqueue_batch_done {
246 $dbh->{AutoCommit} = 0;
247 my $sth = $dbh->prepare("UPDATE zebraqueue SET done = 1 WHERE id = ?");
249 foreach my $id (map { $_->{id} } @$entries) {
252 $dbh->{AutoCommit} = 1;
255 sub select_all_records {
256 my $record_type = shift;
257 return ($record_type eq 'biblio') ? select_all_biblios() : select_all_authorities();
260 sub select_all_authorities {
261 my $sth = $dbh->prepare("SELECT authid FROM auth_header");
266 sub select_all_biblios {
267 my $sth = $dbh->prepare("SELECT biblionumber FROM biblioitems ORDER BY biblionumber");
272 sub export_marc_records_from_sth {
273 my ($record_type, $sth, $directory, $as_xml, $noxml) = @_;
275 my $num_exported = 0;
276 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
278 while (my ($record_number) = $sth->fetchrow_array) {
279 print "." if ( $verbose_logging );
280 print "\r$i" unless ($i++ %100 or !$verbose_logging);
281 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
283 # FIXME - when more than one record is exported and $as_xml is true,
284 # the output file is not valid XML - it's just multiple <record> elements
285 # strung together with no single root element. zebraidx doesn't seem
286 # to care, though, at least if you're using the GRS-1 filter. It does
287 # care if you're using the DOM filter, which requires valid XML file(s).
288 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
292 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
294 return $num_exported;
297 sub export_marc_records_from_list {
298 my ($record_type, $entries, $directory, $as_xml, $noxml) = @_;
300 my $num_exported = 0;
301 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
304 foreach my $record_number ( map { $_->{biblio_auth_number} }
305 grep { !$found{ $_->{biblio_auth_number} }++ }
307 print "." if ( $verbose_logging );
308 print "\r$i" unless ($i++ %100 or !$verbose_logging);
309 my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
311 # FIXME - when more than one record is exported and $as_xml is true,
312 # the output file is not valid XML - it's just multiple <record> elements
313 # strung together with no single root element. zebraidx doesn't seem
314 # to care, though, at least if you're using the GRS-1 filter. It does
315 # care if you're using the DOM filter, which requires valid XML file(s).
316 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
320 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
322 return $num_exported;
325 sub generate_deleted_marc_records {
326 my ($record_type, $entries, $directory, $as_xml) = @_;
328 my $num_exported = 0;
329 open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
331 foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
332 print "\r$i" unless ($i++ %100 or !$verbose_logging);
333 print "." if ( $verbose_logging );
335 my $marc = MARC::Record->new();
336 if ($record_type eq 'biblio') {
337 fix_biblio_ids($marc, $record_number, $record_number);
339 fix_authority_id($marc, $record_number);
341 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
342 fix_unimarc_100($marc);
345 print OUT ($as_xml) ? $marc->as_xml_record() : $marc->as_usmarc();
348 print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
350 return $num_exported;
355 sub get_corrected_marc_record {
356 my ($record_type, $record_number, $noxml) = @_;
358 my $marc = get_raw_marc_record($record_type, $record_number, $noxml);
362 if ($record_type eq 'biblio') {
363 my $succeeded = fix_biblio_ids($marc, $record_number);
364 return unless $succeeded;
366 fix_authority_id($marc, $record_number);
368 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
369 fix_unimarc_100($marc);
376 sub get_raw_marc_record {
377 my ($record_type, $record_number, $noxml) = @_;
380 if ($record_type eq 'biblio') {
382 my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?");
383 $fetch_sth->execute($record_number);
384 if (my ($blob) = $fetch_sth->fetchrow_array) {
385 $marc = MARC::Record->new_from_usmarc($blob);
386 $fetch_sth->finish();
388 return; # failure to find a bib is not a problem -
389 # a delete could have been done before
390 # trying to process a record update
393 eval { $marc = GetMarcBiblio($record_number); };
395 # here we do warn since catching an exception
396 # means that the bib was found but failed
398 warn "error retrieving biblio $record_number";
403 eval { $marc = GetAuthority($record_number); };
405 warn "error retrieving authority $record_number";
413 # FIXME - this routine is suspect
414 # It blanks the Leader/00-05 and Leader/12-16 to
415 # force them to be recalculated correct when
416 # the $marc->as_usmarc() or $marc->as_xml() is called.
417 # But why is this necessary? It would be a serious bug
418 # in MARC::Record (definitely) and MARC::File::XML (arguably)
419 # if they are emitting incorrect leader values.
422 my $leader = $marc->leader;
423 substr($leader, 0, 5) = ' ';
424 substr($leader, 10, 7) = '22 ';
425 $marc->leader(substr($leader, 0, 24));
429 # FIXME - it is essential to ensure that the biblionumber is present,
430 # otherwise, Zebra will choke on the record. However, this
431 # logic belongs in the relevant C4::Biblio APIs.
433 my $biblionumber = shift;
434 my $biblioitemnumber;
436 $biblioitemnumber = shift;
438 my $sth = $dbh->prepare(
439 "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
440 $sth->execute($biblionumber);
441 ($biblioitemnumber) = $sth->fetchrow_array;
443 unless ($biblioitemnumber) {
444 warn "failed to get biblioitemnumber for biblio $biblionumber";
449 # FIXME - this is cheating on two levels
450 # 1. C4::Biblio::_koha_marc_update_bib_ids is meant to be an internal function
451 # 2. Making sure that the biblionumber and biblioitemnumber are correct and
452 # present in the MARC::Record object ought to be part of GetMarcBiblio.
454 # On the other hand, this better for now than what rebuild_zebra.pl used to
455 # do, which was duplicate the code for inserting the biblionumber
456 # and biblioitemnumber
457 C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber);
462 sub fix_authority_id {
463 # FIXME - as with fix_biblio_ids, the authid must be present
464 # for Zebra's sake. However, this really belongs
465 # in C4::AuthoritiesMarc.
466 my ($marc, $authid) = @_;
467 unless ($marc->field('001') and $marc->field('001')->data() eq $authid){
468 $marc->delete_field($marc->field('001'));
469 $marc->insert_fields_ordered(MARC::Field->new('001',$authid));
473 sub fix_unimarc_100 {
474 # FIXME - again, if this is necessary, it belongs in C4::AuthoritiesMarc.
478 if ( length($marc->subfield( 100, "a" )) == 35 ) {
479 $string = $marc->subfield( 100, "a" );
480 my $f100 = $marc->field(100);
481 $marc->delete_field($f100);
484 $string = POSIX::strftime( "%Y%m%d", localtime );
486 $string = sprintf( "%-*s", 35, $string );
488 substr( $string, 22, 6, "frey50" );
489 unless ( length($marc->subfield( 100, "a" )) == 35 ) {
490 $marc->delete_field($marc->field(100));
491 $marc->insert_grouped_field(MARC::Field->new( 100, "", "", "a" => $string ));
496 my ($record_type, $op, $record_dir, $reset_index, $noshadow, $record_format, $zebraidx_log_opt) = @_;
498 my $zebra_server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
499 my $zebra_db_name = ($record_type eq 'biblio') ? 'biblios' : 'authorities';
500 my $zebra_config = C4::Context->zebraconfig($zebra_server)->{'config'};
501 my $zebra_db_dir = C4::Context->zebraconfig($zebra_server)->{'directory'};
503 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name init") if $reset_index;
504 system("zebraidx -c $zebra_config $zebraidx_log_opt $noshadow -g $record_format -d $zebra_db_name $op $record_dir");
505 system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name commit") unless $noshadow;
511 $0: reindex MARC bibs and/or authorities in Zebra.
513 Use this batch job to reindex all biblio or authority
514 records in your Koha database. This job is useful
515 only if you are using Zebra; if you are using the 'NoZebra'
516 mode, this job should not be used.
519 -b index bibliographic records
521 -a index authority records
523 -z select only updated and deleted
524 records marked in the zebraqueue
525 table. Cannot be used with -r
528 -r clear Zebra index before
529 adding records to index
531 -d Temporary directory for indexing.
532 If not specified, one is automatically
533 created. The export directory
534 is automatically deleted unless
535 you supply the -k switch.
537 -k Do not delete export directory.
539 -s Skip export. Used if you have
540 already exported the records
543 -noxml index from ISO MARC blob
544 instead of MARC XML. This
545 option is recommended only
548 -x export and index as xml instead of is02709 (biblios only).
549 use this if you might have records > 99,999 chars,
551 -w skip shadow indexing for this batch
553 -y do NOT clear zebraqueue after indexing; normally,
554 after doing batch indexing, zebraqueue should be
555 marked done for the affected record type(s) so that
556 a running zebraqueue_daemon doesn't try to reindex
557 the same records - specify -y to override this.
558 Cannot be used with -z.
560 -v increase the amount of logging. Normally only
561 warnings and errors from the indexing are shown.
563 -munge-config Deprecated option to try
564 to fix Zebra config files.
565 --help or -h show this message.
569 # FIXME: the following routines are deprecated and
570 # will be removed once it is determined whether
571 # a script to fix Zebra configuration files is
575 # creating zebra-biblios.cfg depending on system
578 # getting zebraidx directory
580 foreach (qw(/usr/local/bin/zebraidx
589 unless ($zebraidxdir) {
591 ERROR: could not find zebraidx directory
592 ERROR: Either zebra is not installed,
593 ERROR: or it's in a directory I don't checked.
594 ERROR: do a which zebraidx and edit this file to add the result you get
598 $zebraidxdir =~ s/\/bin\/.*//;
599 print "Info : zebra is in $zebraidxdir \n";
601 # getting modules directory
603 foreach (qw(/usr/local/lib/idzebra-2.0/modules/mod-grs-xml.so
604 /usr/local/lib/idzebra/modules/mod-grs-xml.so
605 /usr/lib/idzebra/modules/mod-grs-xml.so
606 /usr/lib/idzebra-2.0/modules/mod-grs-xml.so
613 unless ($modulesdir) {
615 ERROR: could not find mod-grs-xml.so directory
616 ERROR: Either zebra is not properly compiled (libxml2 is not setup and you don t have mod-grs-xml.so,
617 ERROR: or it's in a directory I don't checked.
618 ERROR: find where mod-grs-xml.so is and edit this file to add the result you get
622 $modulesdir =~ s/\/modules\/.*//;
623 print "Info: zebra modules dir : $modulesdir\n";
625 # getting tab directory
627 foreach (qw(/usr/local/share/idzebra/tab/explain.att
628 /usr/local/share/idzebra-2.0/tab/explain.att
629 /usr/share/idzebra/tab/explain.att
630 /usr/share/idzebra-2.0/tab/explain.att
639 ERROR: could not find explain.att directory
640 ERROR: Either zebra is not properly compiled,
641 ERROR: or it's in a directory I don't checked.
642 ERROR: find where explain.att is and edit this file to add the result you get
646 $tabdir =~ s/\/tab\/.*//;
647 print "Info: tab dir : $tabdir\n";
650 # AUTHORITIES creating directory structure
652 my $created_dir_or_file = 0;
654 if ( $verbose_logging ) {
655 print "====================\n";
656 print "checking directories & files for authorities\n";
657 print "====================\n";
659 unless (-d "$authorityserverdir") {
660 system("mkdir -p $authorityserverdir");
661 print "Info: created $authorityserverdir\n";
662 $created_dir_or_file++;
664 unless (-d "$authorityserverdir/lock") {
665 mkdir "$authorityserverdir/lock";
666 print "Info: created $authorityserverdir/lock\n";
667 $created_dir_or_file++;
669 unless (-d "$authorityserverdir/register") {
670 mkdir "$authorityserverdir/register";
671 print "Info: created $authorityserverdir/register\n";
672 $created_dir_or_file++;
674 unless (-d "$authorityserverdir/shadow") {
675 mkdir "$authorityserverdir/shadow";
676 print "Info: created $authorityserverdir/shadow\n";
677 $created_dir_or_file++;
679 unless (-d "$authorityserverdir/tab") {
680 mkdir "$authorityserverdir/tab";
681 print "Info: created $authorityserverdir/tab\n";
682 $created_dir_or_file++;
684 unless (-d "$authorityserverdir/key") {
685 mkdir "$authorityserverdir/key";
686 print "Info: created $authorityserverdir/key\n";
687 $created_dir_or_file++;
690 unless (-d "$authorityserverdir/etc") {
691 mkdir "$authorityserverdir/etc";
692 print "Info: created $authorityserverdir/etc\n";
693 $created_dir_or_file++;
697 # AUTHORITIES : copying mandatory files
699 # the record model, depending on marc flavour
700 unless (-f "$authorityserverdir/tab/record.abs") {
701 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
702 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/authorities/record.abs $authorityserverdir/tab/record.abs");
703 print "Info: copied record.abs for UNIMARC\n";
705 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/authorities/record.abs $authorityserverdir/tab/record.abs");
706 print "Info: copied record.abs for USMARC\n";
708 $created_dir_or_file++;
710 unless (-f "$authorityserverdir/tab/sort-string-utf.chr") {
711 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/sort-string-utf.chr");
712 print "Info: copied sort-string-utf.chr\n";
713 $created_dir_or_file++;
715 unless (-f "$authorityserverdir/tab/word-phrase-utf.chr") {
716 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $authorityserverdir/tab/word-phrase-utf.chr");
717 print "Info: copied word-phase-utf.chr\n";
718 $created_dir_or_file++;
720 unless (-f "$authorityserverdir/tab/auth1.att") {
721 system("cp -f $kohadir/etc/zebradb/authorities/etc/bib1.att $authorityserverdir/tab/auth1.att");
722 print "Info: copied auth1.att\n";
723 $created_dir_or_file++;
725 unless (-f "$authorityserverdir/tab/default.idx") {
726 system("cp -f $kohadir/etc/zebradb/etc/default.idx $authorityserverdir/tab/default.idx");
727 print "Info: copied default.idx\n";
728 $created_dir_or_file++;
731 unless (-f "$authorityserverdir/etc/ccl.properties") {
732 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
733 system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties");
734 print "Info: copied ccl.properties\n";
735 $created_dir_or_file++;
737 unless (-f "$authorityserverdir/etc/pqf.properties") {
738 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn});
739 system("cp -f $kohadir/etc/zebradb/pqf.properties $authorityserverdir/etc/pqf.properties");
740 print "Info: copied pqf.properties\n";
741 $created_dir_or_file++;
745 # AUTHORITIES : copying mandatory files
747 unless (-f C4::Context->zebraconfig('authorityserver')->{config}) {
748 open ZD,">:utf8 ",C4::Context->zebraconfig('authorityserver')->{config};
750 # generated by KOHA/misc/migration_tools/rebuild_zebra.pl
751 profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
754 # Files that describe the attribute sets supported.
759 modulePath:$modulesdir/modules/
760 # Specify record type
761 iso2709.recordType:grs.marcxml.record
763 recordId: (auth1,Local-Number)
769 lockDir: $authorityserverdir/lock
772 register: $authorityserverdir/register:4G
773 shadow: $authorityserverdir/shadow:4G
775 # Temp File area for result sets
776 setTmpDir: $authorityserverdir/tmp
778 # Temp File area for index program
779 keyTmpDir: $authorityserverdir/key
781 # Approx. Memory usage during indexing
785 print "Info: creating zebra-authorities.cfg\n";
786 $created_dir_or_file++;
789 if ($created_dir_or_file) {
790 print "Info: created : $created_dir_or_file directories & files\n";
792 print "Info: file & directories OK\n";
797 if ( $verbose_logging ) {
798 print "====================\n";
799 print "checking directories & files for biblios\n";
800 print "====================\n";
804 # BIBLIOS : creating directory structure
806 unless (-d "$biblioserverdir") {
807 system("mkdir -p $biblioserverdir");
808 print "Info: created $biblioserverdir\n";
809 $created_dir_or_file++;
811 unless (-d "$biblioserverdir/lock") {
812 mkdir "$biblioserverdir/lock";
813 print "Info: created $biblioserverdir/lock\n";
814 $created_dir_or_file++;
816 unless (-d "$biblioserverdir/register") {
817 mkdir "$biblioserverdir/register";
818 print "Info: created $biblioserverdir/register\n";
819 $created_dir_or_file++;
821 unless (-d "$biblioserverdir/shadow") {
822 mkdir "$biblioserverdir/shadow";
823 print "Info: created $biblioserverdir/shadow\n";
824 $created_dir_or_file++;
826 unless (-d "$biblioserverdir/tab") {
827 mkdir "$biblioserverdir/tab";
828 print "Info: created $biblioserverdir/tab\n";
829 $created_dir_or_file++;
831 unless (-d "$biblioserverdir/key") {
832 mkdir "$biblioserverdir/key";
833 print "Info: created $biblioserverdir/key\n";
834 $created_dir_or_file++;
836 unless (-d "$biblioserverdir/etc") {
837 mkdir "$biblioserverdir/etc";
838 print "Info: created $biblioserverdir/etc\n";
839 $created_dir_or_file++;
843 # BIBLIOS : copying mandatory files
845 # the record model, depending on marc flavour
846 unless (-f "$biblioserverdir/tab/record.abs") {
847 if (C4::Context->preference("marcflavour") eq "UNIMARC") {
848 system("cp -f $kohadir/etc/zebradb/marc_defs/unimarc/biblios/record.abs $biblioserverdir/tab/record.abs");
849 print "Info: copied record.abs for UNIMARC\n";
851 system("cp -f $kohadir/etc/zebradb/marc_defs/marc21/biblios/record.abs $biblioserverdir/tab/record.abs");
852 print "Info: copied record.abs for USMARC\n";
854 $created_dir_or_file++;
856 unless (-f "$biblioserverdir/tab/sort-string-utf.chr") {
857 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/sort-string-utf.chr");
858 print "Info: copied sort-string-utf.chr\n";
859 $created_dir_or_file++;
861 unless (-f "$biblioserverdir/tab/word-phrase-utf.chr") {
862 system("cp -f $kohadir/etc/zebradb/lang_defs/fr/sort-string-utf.chr $biblioserverdir/tab/word-phrase-utf.chr");
863 print "Info: copied word-phase-utf.chr\n";
864 $created_dir_or_file++;
866 unless (-f "$biblioserverdir/tab/bib1.att") {
867 system("cp -f $kohadir/etc/zebradb/biblios/etc/bib1.att $biblioserverdir/tab/bib1.att");
868 print "Info: copied bib1.att\n";
869 $created_dir_or_file++;
871 unless (-f "$biblioserverdir/tab/default.idx") {
872 system("cp -f $kohadir/etc/zebradb/etc/default.idx $biblioserverdir/tab/default.idx");
873 print "Info: copied default.idx\n";
874 $created_dir_or_file++;
876 unless (-f "$biblioserverdir/etc/ccl.properties") {
877 # system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
878 system("cp -f $kohadir/etc/zebradb/ccl.properties $biblioserverdir/etc/ccl.properties");
879 print "Info: copied ccl.properties\n";
880 $created_dir_or_file++;
882 unless (-f "$biblioserverdir/etc/pqf.properties") {
883 # system("cp -f $kohadir/etc/zebradb/pqf.properties ".C4::Context->zebraconfig('biblioserver')->{ccl2rpn});
884 system("cp -f $kohadir/etc/zebradb/pqf.properties $biblioserverdir/etc/pqf.properties");
885 print "Info: copied pqf.properties\n";
886 $created_dir_or_file++;
890 # BIBLIOS : copying mandatory files
892 unless (-f C4::Context->zebraconfig('biblioserver')->{config}) {
893 open ZD,">:utf8 ",C4::Context->zebraconfig('biblioserver')->{config};
895 # generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl
896 profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
899 # Files that describe the attribute sets supported.
904 modulePath:$modulesdir/modules/
905 # Specify record type
906 iso2709.recordType:grs.marcxml.record
908 recordId: (bib1,Local-Number)
914 lockDir: $biblioserverdir/lock
917 register: $biblioserverdir/register:4G
918 shadow: $biblioserverdir/shadow:4G
920 # Temp File area for result sets
921 setTmpDir: $biblioserverdir/tmp
923 # Temp File area for index program
924 keyTmpDir: $biblioserverdir/key
926 # Approx. Memory usage during indexing
930 print "Info: creating zebra-biblios.cfg\n";
931 $created_dir_or_file++;
934 if ($created_dir_or_file) {
935 print "Info: created : $created_dir_or_file directories & files\n";
937 print "Info: file & directories OK\n";