Bug 24735: Remove QueryParser-related code
[koha-equinox.git] / t / db_dependent / zebra_config.pl
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4
5 use File::Copy;
6 use File::Path qw(make_path);
7 use File::Find;
8 use File::Basename;
9 use File::Spec;
10
11 use C4::Context;
12
13 my $source = File::Spec->rel2abs('.');
14 my $destination = $ARGV[0];
15 my $marc_type = $ARGV[1] || 'marc21';
16 my $indexing_mode = $ARGV[2] || 'dom';
17
18 $ENV{__ZEBRA_MARC_FORMAT__} = $marc_type;
19 $ENV{__ZEBRA_BIB_CFG__} = 'zebra-biblios-dom.cfg';
20 $ENV{__BIB_RETRIEVAL_CFG__} = 'retrieval-info-bib-dom.xml';
21 $ENV{__ZEBRA_AUTH_CFG__} = 'zebra-authorities-dom.cfg';
22 $ENV{__AUTH_RETRIEVAL_CFG__} = 'retrieval-info-auth-dom.xml';
23
24 make_path("$destination/var/lock/zebradb");
25 make_path("$destination/var/lock/zebradb/biblios");
26 make_path("$destination/var/lock/zebradb/authorities");
27 make_path("$destination/var/lock/zebradb/rebuild");
28 make_path("$destination/var/lib/zebradb");
29 make_path("$destination/var/lib/zebradb/biblios");
30 make_path("$destination/var/lib/zebradb/biblios/key");
31 make_path("$destination/var/lib/zebradb/biblios/register");
32 make_path("$destination/var/lib/zebradb/biblios/shadow");
33 make_path("$destination/var/lib/zebradb/biblios/tmp");
34 make_path("$destination/var/lib/zebradb/authorities");
35 make_path("$destination/var/lib/zebradb/authorities/key");
36 make_path("$destination/var/lib/zebradb/authorities/register");
37 make_path("$destination/var/lib/zebradb/authorities/shadow");
38 make_path("$destination/var/lib/zebradb/authorities/tmp");
39 make_path("$destination/var/run/zebradb");
40
41 $ENV{'INSTALL_BASE'} = $destination;
42 $ENV{'__INSTALL_BASE__'} = $destination;
43
44 $ENV{'__DB_TYPE__'} = C4::Context->config('db_scheme') // 'mysql';
45 $ENV{'__DB_NAME__'} = C4::Context->config('database')  // 'koha';
46 $ENV{'__DB_HOST__'} = C4::Context->config('hostname')  // 'localhost';
47 $ENV{'__DB_PORT__'} = C4::Context->config('port')      // '3306';
48 $ENV{'__DB_USER__'} = C4::Context->config('user')      // 'kohaadmin';
49 $ENV{'__DB_PASS__'} = C4::Context->config('pass')      // 'katikoan';
50
51 my @files = ( "$source/etc/koha-conf.xml",
52             );
53
54 find(sub { push @files, $File::Find::name if ( -f $File::Find::name ); }, "$source/etc/zebradb");
55
56 foreach my $file (@files) {
57     my $target = "$file";
58     $target =~ s#$source#$destination#;
59     $target =~ s#etc/zebradb#etc/koha/zebradb#;
60     unlink($target);
61     make_path(dirname($target));
62     copy("$file", "$target");
63     system("perl $source/rewrite-config.PL $target");
64     if ($file =~ m/xml/) {
65         replace("$target", "$destination/intranet/templates", "$source/koha-tmpl/intranet-tmpl");
66     }
67 }
68
69
70 sub replace {
71     my ($file, $pattern, $replacement) = @_;
72     system("sed -i -e 's#$pattern#$replacement#' $file");
73 }