#!/opt/casp/tools/bin/linux2/perl5/bin/perl -I/opt/casp/tools/bin/linux2/perl5/lib -I/opt/casp use INSTALL::common; use INSTALL::global; use INSTALL::parameter; use INSTALL::os; use INSTALL::query; use INSTALL::webserver; 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} = "/opt/casp"; $pParameters->{com_layer} = "chilicom"; INSTALL::common::set_standard_globals; my $pGlobals = \%INSTALL::global::variables; my $pOS = \%INSTALL::os::Details; my $program_name = "configure-server"; my $debug = 0; #============================================================================== #------------------------ Helper routines. #============================================================================== # # describes the usage for the main usage menu. # sub usage { report ("", "usage: configure-server function=". "", "===============================================================================", " The configure-server script runs both interactively and non-interactively. In", " non-interactive mode, a function= must be provided, also making", " certain to pass the required arguments for (see below).", " Interactively, only the marketing-approved functionality is exposed to the", " user.", "-------------------------------------------------------------------------------", " function=add-server", " - Create a new Sun Chili!Soft ASP to webserver linkage.", "-------------------------------------------------------------------------------", " webserver_conf= (user-specified)", " - Specifies the location of your web server configuration file", " to create a webserver-to-asp link with.", " webserver_binary= (default=auto-detect)", " - Specifies the location of your web server binary file.", " webserver_restart= (default=yes)", " - Specifies whether or not to restart your web server once", " Sun Chili!Soft ASP has been configured.", " webserver_overwrite= (default=no)", " - Specifies whether to overwrite any previous Sun Chili!Soft ASP", " currently linked to the specified webserver.", " install_samples= (default=yes)", " - Specifies whether or not the Sun Chili!Soft ASP samples application", " should be made visible to the webserver (/caspsamp).", " install_docs= (default=yes)", " - Specifies whether or not the Sun Chili!Soft ASP documentation", " application should be made visible to the webserver (/caspdoc).", " start_asp= (default=yes)", " - Specifies whether Sun Chili!Soft ASP should be started once", " configuration is complete.", " start_asp_onboot= (default=yes)", " - Specifies whether Sun Chili!Soft ASP should be started on system", " reboot.", "-------------------------------------------------------------------------------", " function=change-server", " - Change an existing Sun Chili!Soft ASP to webserver linkage, by linking", " to a new webserver.", "-------------------------------------------------------------------------------", " engine_dir= or engine= (user-specified)", " - Specifies the path to the directory containing the Sun Chili!Soft ASP", " engine whose linkage you wish to change.", " engine_name= (user-specified)", " - Specifies the last component of an engine_dir, allowing the script", " to discern the full path.", " webserver_conf= (user-specified)", " - Specifies the location of the webserver configuration file which you", " wish to reconfigure the specified Sun Chili!Soft ASP engine linkage", " to.", " webserver_binary= (default=auto-detect)", " - Specifies the location of your webserver binary file.", " webserver_restart= (default=yes)", " - Specifies whether or not the webserver should be restarted after", " it has been configured to run with Sun Chili!Soft ASP.", "-------------------------------------------------------------------------------", " function=delete-server", " - Delete an existing Sun Chili!Soft ASP to webserver linkage.", "-------------------------------------------------------------------------------", " engine_dir= or engine= (user-specified)", " - Specifies the path to the directory containing the Sun Chili!Soft ASP", " engine whose linkage you wish removed.", " engine_name= (user-specified)", " - Specifies the last component of an engine_dir, allowing the script", " to discern the full path.", "-------------------------------------------------------------------------------", " function=configure-java", " - Change the location of the utilized JRE (or turn Java support off", " altogether).", "-------------------------------------------------------------------------------", " jre_path= (default=bundled JRE path)", " - Specifies the location of a user specified JRE. If this path is left", " unspecified, and Sun Chili!Soft ASP bundles a JRE, that JRE will be", " assumed.", " jre_enabled= (default=yes)", " - Specifies whether or not to enable or disable java support,", " altogether. No specifies that no jre should be enabled, whereas yes", " indicates that the user specified JRE (via jre_path) or implicit", " bundled JRE, should be enabled.", "-------------------------------------------------------------------------------", " function=configure-boot", " - Allows the user to configure whether or not a Sun Chili!Soft ASP engine", " will start on system boot. If boot_enabled is left unspecified (see", " below), not configuration change will be performed, but instead the", " current status of 'start on system boot' will be returned via exit", " code. If 'start on system boot' is enabled, the exit code will be 0,", " else 1.", "-------------------------------------------------------------------------------", " engine_dir= or engine= (user-specified)", " - Specifies the path to the directory containing the Sun Chili!Soft ASP", " engine whose configuration is being altered.", " engine_name= (user-specified)", " - Specifies the last component of an engine_dir, allowing the script", " to discern the full path.", " boot_enabled= (user-specified)", " - Specifies whether or not the associated Sun Chili!Soft ASP engine", " should be start upon system boot.", "===============================================================================" ); exit(1); } #============================================================================== #------------------------ Provide execution functionality. #============================================================================== sub exec_script { (@_ >= 1) || die "Invalid number of arguments"; my $script = shift @_; my $script_dir = "$pParameters->{asphome}/INSTALL"; my $functional_script = "$script_dir/$script"; if (-x $functional_script) { my $pid = fork; if ($pid) { wait; my $exit_code = $?; if ($debug && ($exit_code && 0xff)) { report("Process died with lower bits of: ".($exit_code && 0xff)); } exit($? >> 8); } else { if ($debug) { print STDERR ("Executing: $functional_script ", (map { "'$_' " } @_), "\n"); } exec("$functional_script",@_); } } else { my $script_pattern = $script; $script_pattern =~ s/[-_]/[-_]/g; local *DIR; if (opendir(DIR,$script_dir)) { foreach my $element (readdir(DIR)) { if (($element =~ /^$script_pattern$/) && (-x "$script_dir/$element")) { exec_script($element,@_); } } closedir(DIR); } error("Unable to locate script '$script'."); } } #============================================================================== #------------------------ Main routine. #============================================================================== # This script is required to support both interactive and # non-interactive mode. #============================================================================== #------------------------ Validate all the required parameters. #============================================================================== my %PARAM_REQUIREMENTS = ( REQUIRED => [ 'function' ], VALUES => { 'function' => [ 'add[-_]server', 'delete[-_]server', 'change[-_]server', 'configure[-_]java' ] } ); if (boolean_value($pParameters->{'--help'})) { usage(); } unless(INSTALL::parameter::verify(%PARAM_REQUIREMENTS)) { exit(1); } #============================================================================== #------------------------ Perform the actual configuration steps. #============================================================================== if (interactive) { my $result = INSTALL::query::user_menu ( "Sun Chili!Soft ASP - Server Configuration", "The options listed below allow you to override options selected during installation. ". "For more information, see 'Chapter 2' in the product documentation.", "Which action would you like to perform", "terminal_mark=?", "Configure the ASP Server.", "Configure Java support.", "default=Exit without performing any action." ); if ($result == 1) { # Skip this menu, if no web servers has been installed. my @used_servers = &INSTALL::webserver::load_used_servers ; if (! @used_servers) { exec_script('add-server'); } else { $result = INSTALL::query::user_menu ( "Sun Chili!Soft ASP - Server Configuration", "The options listed below allow you to change the settings specific to an existing ". "Sun Chili!Soft ASP server. For more information about these options, see 'Chapter 2'". "in the product documentation.", "Which action would you like to perform", "terminal_mark=?", "Change the webserver to ASP server association.", "Enable or disable the 'start on system boot' functionality.", "default=Exit without performing any action." ); if ($result == 1) { exec_script('change-server'); } elsif ($result == 2) { exec_script('configure-boot'); } } } elsif ($result == 2) { exec_script('configure-java'); } report("Status: ","No action has been performed."); exit(0); } else { # Non-interactive. my @params = grep { not /function/ } keys %$pParameters; exec_script($pParameters->{function},map("$_=$pParameters->{$_}",@params)); }