source: main/trunk/greenstone2/common-src/cgi-bin/index-server.pl@ 33011

Last change on this file since 33011 was 33011, checked in by ak19, 5 years ago

On Ubuntu 18.04, confirmed Renate's findings that gsdlCGI.pm wasn't found by gliserver.pl in its @INC paths. Have now added the containing cgi-bin folder on GS2 and cgi folder on GS3 to @INC to teach gliserver.pl to find gsdlCGI.pm. This however needed a fix in build.xml where force-start-tomcat was passing the wrong value for GSDL3HOME to tomcat: it was passing in basedir instead of web.home. With this fix, gliserver.pl now works on Ubuntu 18.04. Have added lines identical to the changes in gliserver.pl to the other pl files in the cgi(-bin) folder for those pl files that similarly import gsdlCGI.pm.

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/usr/bin/perl -w
2##!C:\\Perl\\bin\\perl -w
3# If not explicitly associating .pl filename ending with Perl in the
4# web server's configuration file, then need to specify the full path of
5# Perl above
6
7use strict;
8
9BEGIN {
10 # Line to stop annoying child DOS CMD windows from appearing
11 Win32::SetChildShowWindow(0)
12 if defined &Win32::SetChildShowWindow;
13
14 # On Ubuntu 18.04, gsdlCGI.pm can't be found as the cgi folder is not among @INC paths.
15 # Ensure gsdlCGI.pm is available in @INC by adding the cgi folder to it.
16 # For GS2:
17 my $gsdl_cgi_path = $ENV{'GSDLHOME'} . "/cgi-bin";
18 # For GS3:
19 $gsdl_cgi_path = $ENV{'GSDL3HOME'} . "/WEB-INF" . "/cgi" if defined $ENV{'GSDL3HOME'};
20
21 my $found_cgi_path = 0;
22 foreach my $inc_path (@INC) {
23 if($inc_path eq $gsdl_cgi_path) {
24 $found_cgi_path = 1;
25 last;
26 }
27 }
28 if(!$found_cgi_path) {
29 unshift (@INC, $gsdl_cgi_path);
30 }
31}
32
33# Set this to 1 to work around IIS 6 craziness
34my $iis6_mode = 0;
35
36
37# IIS 6: for some reason, IIS runs this script with the working
38# directory set to the Greenstone directory rather than the cgi-bin
39# directory, causing lots of stuff to fail
40if ($iis6_mode)
41{
42 # Change into cgi-bin\<OS> directory
43 chdir("cgi-bin");
44 if(defined $ENV{'GSDLARCH'}) {
45 chdir($ENV{'GSDLOS'}.$ENV{'GSDLARCH'});
46 } else {
47 chdir($ENV{'GSDLOS'});
48 }
49}
50
51
52# We use require and an eval here (instead of "use") to catch any
53# errors loading the module (for IIS)
54eval('require "./gsdlCGI.pm"');
55if ($@)
56{
57 print STDOUT "Content-type:text/plain\n\n";
58 print STDOUT "ERROR: $@\n";
59 exit 0;
60}
61
62sub main
63{
64 my $gsdl_cgi = new gsdlCGI();
65
66 # Load the Greenstone modules that we need to use
67 $gsdl_cgi->setup_gsdl();
68
69 my $gsdlhome = $ENV{'GSDLHOME'};
70 $gsdl_cgi->checked_chdir($gsdlhome);
71
72 require cgiactions::indexaction;
73
74 $gsdl_cgi->parse_cgi_args();
75
76 # We don't want the gsdlCGI module to return errors and warnings in XML
77 $gsdl_cgi->{'xml'} = 0;
78
79 my $action = new indexaction($gsdl_cgi,$iis6_mode);
80
81 $action->do_action();
82}
83
84&main();
Note: See TracBrowser for help on using the repository browser.