Bug 11439: (follow up) add missing rollback call
[koha.git] / t / db_dependent / zebra_config.pl
blob1395508153b733069deb0daee13adeed2bff42a1
1 #!/usr/bin/perl
3 use Modern::Perl;
4 use File::Copy;
5 use File::Path qw(make_path);
6 use File::Find;
7 use File::Basename;
8 use File::Spec;
10 my $source = File::Spec->rel2abs('.');
11 my $destination = $ARGV[0];
12 my $marc_type = $ARGV[1] || 'marc21';
13 my $indexing_mode = $ARGV[2] || 'grs1';
15 $ENV{__ZEBRA_MARC_FORMAT__} = $marc_type;
16 if ($indexing_mode eq 'dom') {
17 $ENV{__ZEBRA_BIB_CFG__} = 'zebra-biblios-dom.cfg';
18 $ENV{__BIB_RETRIEVAL_CFG__} = 'retrieval-info-bib-dom.xml';
19 $ENV{__ZEBRA_AUTH_CFG__} = 'zebra-authorities-dom.cfg';
20 $ENV{__AUTH_RETRIEVAL_CFG__} = 'retrieval-info-auth-dom.xml';
21 } else {
22 $ENV{__ZEBRA_BIB_CFG__} = 'zebra-biblios.cfg';
23 $ENV{__BIB_RETRIEVAL_CFG__} = 'retrieval-info-bib-grs1.xml';
24 $ENV{__ZEBRA_AUTH_CFG__} = 'zebra-authorities.cfg';
25 $ENV{__AUTH_RETRIEVAL_CFG__} = 'retrieval-info-auth-grs1.xml';
28 make_path("$destination/var/lock/zebradb");
29 make_path("$destination/var/lock/zebradb/biblios");
30 make_path("$destination/var/lock/zebradb/authorities");
31 make_path("$destination/var/lib/zebradb");
32 make_path("$destination/var/lib/zebradb/biblios");
33 make_path("$destination/var/lib/zebradb/biblios/key");
34 make_path("$destination/var/lib/zebradb/biblios/register");
35 make_path("$destination/var/lib/zebradb/biblios/shadow");
36 make_path("$destination/var/lib/zebradb/biblios/tmp");
37 make_path("$destination/var/lib/zebradb/authorities");
38 make_path("$destination/var/lib/zebradb/authorities/key");
39 make_path("$destination/var/lib/zebradb/authorities/register");
40 make_path("$destination/var/lib/zebradb/authorities/shadow");
41 make_path("$destination/var/lib/zebradb/authorities/tmp");
42 make_path("$destination/var/run/zebradb");
44 $ENV{'INSTALL_BASE'} = $destination;
45 $ENV{'__INSTALL_BASE__'} = $destination;
47 my @files = ( "$source/etc/koha-conf.xml",
48 "$source/etc/searchengine/queryparser.yaml",
51 find(sub { push @files, $File::Find::name if ( -f $File::Find::name ); }, "$source/etc/zebradb");
53 foreach my $file (@files) {
54 my $target = "$file";
55 $target =~ s#$source#$destination#;
56 $target =~ s#etc/zebradb#etc/koha/zebradb#;
57 unlink($target);
58 make_path(dirname($target));
59 copy("$file", "$target");
60 system("perl $source/rewrite-config.PL $target");
61 if ($file =~ m/xml/) {
62 replace("$target", "$destination/intranet/templates", "$source/koha-tmpl/intranet-tmpl");
67 sub replace {
68 my ($file, $pattern, $replacement) = @_;
69 system("sed -i -e 's#$pattern#$replacement#' $file");