#!<> use INSTALL::common; use INSTALL::global; use INSTALL::parameter; use INSTALL::locale; use strict; my $pParameters = \%INSTALL::parameter::variables; #============================================================================== #------------------------ Make sure that the user is a root #============================================================================== if ($> != 0) { print STDOUT "You will need to be root to execute this script.\n"; exit 1; } #============================================================================== #------------------------ Default global values #============================================================================== $pParameters->{asphome} = "<>"; $pParameters->{com_layer} = "<>"; INSTALL::common::set_standard_globals; my $pGlobals = \%INSTALL::global::variables; my $pOS = \%INSTALL::os::Details; my $debug = 0; #------------------------------------------------------------------------------ # This routine is responsbile for enabling or disabling the 'javasupport' # from 'casp.cnfg' file. # This routine looks at '.installed_db' to get the list of ASP Engines # installed at this location and for each of the asp instances, we will update # java support status. # returns undef on error and 1 on success. #------------------------------------------------------------------------------ sub update_javasupport { my ($enable_java) = (@_) ; $enable_java = (boolean_value($enable_java)) ? "yes" : "no" ; my $pIni = INSTALL::ini::open($pGlobals->{installed_db}); if (! $pIni) { error ("Unable to get the list of Installed ASP Engines.", "Reason: unable to open '$pGlobals->{installed_db}' file."); return (undef); } # Get the list of ASP Instance installed at this location. my @engine_dirs ; my @section_list = INSTALL::ini::getSectionNames($pIni); if (! @section_list) { # It seems that we have no ASP Engine has been installed here. # so we have nothing to do here. return (undef); } my $warn_user ; my $error_occurred ; # For each of these ASP Instances,disable the java support in casp.cnfg file. foreach my $sectionName (@section_list) { my $pEngine = INSTALL::ini::openSection($pIni,$sectionName); unless ( $pEngine || (-d "$pEngine->{engine_dir}")) { error ("Unable to validate for a valid ASP Engine - '$sectionName'."); $error_occurred = 1 ; next ; } my $conf = "$pEngine->{engine_dir}/casp.cnfg" ; my $dupname = "$pEngine->{engine_dir}/casp.cnfg.pre-java" ; unless (-r "$conf") { error("Engine configuration file - '$conf' either does not exist or is not readable."); $error_occurred = 1 ; next ; } unlink($dupname); copy($conf,$dupname); unless (open(SRC,"<$dupname") && open(CASP,">$conf")) { close(SRC); close(CASP); $error_occurred = 1; unlink($conf); copy($dupname,$conf); unlink($dupname); error("Unable to open the server configuration file - '$conf'.", "You will need to manually set javasupport to 'no' in this file."); next ; } while () { my $line = $_ ; s/(^\s*javasupport\s*=\s*)(\S+)/javasupport = $enable_java/ ; s/(^\s*restart\s*=\s*)(\S+)/restart = yes/ ; print CASP ; print CASP "\n" unless (chomp($line)); } $warn_user = 1; close(CASP); close(SRC); } # if there is a ASP Engine installed, then we need to inform our customer # that he needs to restart his ASP Engines manually. if ($warn_user) { report("WARNING:"," You will need to restart your ASP Engines for this change to reflect."); } return (!$error_occurred); } #============================================================================== #============================================================================== #------------------------ Validate all the required parameters. #============================================================================== # The variables may be set to anything, there aren't any constraints. my %PARAM_REQUIREMENTS = ( OPTIONAL => ['jre_path', 'jre_enabled'], ); if (INSTALL::parameter::verify(%PARAM_REQUIREMENTS)) { use INSTALL::bean; my $result = INSTALL::bean::configure; if ($result > 0) { report("Status: ","Java support was configured successfully!"); exit(0); } elsif ($result == 0) { # Now, remove the javasupport flag from the casp.cnfg file in all of the # ASP Instances. report("Status: ","Java support has been disabled."); &update_javasupport("no"); exit(1); } else { report("Status: ","Java support was left unchanged."); } }