source: gs3-extensions/solr/trunk/src/solr-setup.pl

Last change on this file was 24446, checked in by davidb, 13 years ago

Start of Solr extension for Greenstone3

File size: 1.6 KB
Line 
1
2BEGIN {
3 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
4 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
5 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
6 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
7}
8
9use Cwd;
10require util;
11
12my $env_ext = "GEXT_SOLR";
13my $ext_desc = "the SOLR Extension";
14
15if (!defined $ENV{$env_ext}) {
16
17 my $ext_home = cwd();
18 $ENV{$env_ext} = $ext_home;
19
20 my $ext_bin_script = &util::filename_cat($ENV{$env_ext},"bin","script");
21 my $ext_lib = &util::filename_cat($ENV{$env_ext},"lib");
22
23 if (-d $ext_bin_script) {
24 &util::envvar_prepend("PATH",$ext_bin_script);
25 }
26
27 if (-d $ext_lib) {
28 if ($ENV{'GSDLOS'} =~ m/windows/i) {
29 &util::envvar_prepend("PATH",$ext_lib);
30 }
31 elsif ($ENV{'GSDLOS'} =~ m/darwin/i) {
32 &util::envvar_prepend("DYLD_LIBRARY_PATH",$ext_lib);
33 }
34 else { # linux
35 &util::envvar_prepend("LD_LIBRARY_PATH",$ext_lib);
36 }
37 }
38
39 if ($ENV{'GSDLOS'} =~ m/windows/i) {
40 $ENV{'GS_CP_SET'} = "yes";
41 }
42
43 my ($ext_dir,$_prefix_dir) = File::Basename::fileparse($ext_home);
44 # GSDLEXTS always uses : as a separator
45 if (defined $ENV{'GSDLEXTS'}) {
46 $ENV{'GSDLEXTS'} .= ":$ext_dir";
47 }
48 else {
49 $ENV{'GSDLEXTS'} = $ext_dir;
50 }
51
52 print STDERR "+Your environment is now setup for $ext_desc\n";
53}
54else {
55 print STDERR "+Your environment is already setup for $ext_desc\n";
56}
57
58if (scalar(@ARGV>0)) {
59
60 print STDERR "\n";
61
62 my $cmd = join(" ",map {$_ = "\"$_\""} @ARGV);
63
64 if (system($cmd)!=0) {
65 print STDERR "\nError: Failed to run '$cmd'\n";
66 print STDERR "$!\n";
67 }
68}
69
701;
Note: See TracBrowser for help on using the repository browser.