package INSTALL::zeus; use INSTALL::common; use INSTALL::os; use INSTALL::query; use strict; my $debug = 0; # NOTE: ASP is supported under Zeus through the use of the Zeus # NSAPI-support module. That module must be configured and enabled # through the Zeus admin console for the specific server which ASP # is being installed to. By default this will create a subdirectory # called ns-config under the Zeus installation root. Below that ns-config # directory, the tree looks like a skimpy Netscape install (only the # 'config' subdirectory exists). # # /ns-config//config/*.conf,mime.types # this is the constant flag, we need to use, if we decide to support # version dependent netscape/zeus modules. If we support version dependent # netscape modules, then there needs to be a corresponding # netscape_versions in the module directory. # if this flag is set to Zero, we assume that there will be a directory # called netscape under the modules directory,without any versions. my $CONST_UseZeusVersions = 0; my $pGlobals = \%INSTALL::global::variables; my $pParameters = \%INSTALL::parameter::variables; my $pOS = \%INSTALL::os::Details; my $CONST_ZeusStartScript = "rc.d/S20web"; my $CONST_StartScript = "webadmin/bin/startserver.sh"; my $CONST_StopScript = "webadmin/bin/stopserver.sh"; sub confirm_existence { ($#_ == 0) || die "Invalid number of arguments."; my ($file) = @_; if ($file eq "none") { report(""); my $answer = INSTALL::query::user ("Would you like to cancel the setup","terminal_mark=?","y","default=n"); report(""); if ($answer eq "y") { return(1); } else { # Cause a requery. return(undef); } } elsif (not -f $file) { report("Invalid: The specified file does not exist."); report(""); } return(-f $file); } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # External functions #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #------------------------------------------------------------------------------ # This method attempts to find an Zeus server located in the directory # specified. It does this by checking for an magnus.conf file in the conf # subdirectory under this directory. If a configuration file (or files) is # found, they are returned as a list. #------------------------------------------------------------------------------ sub locate_server { sub isDir { ($#_ == 0) || die "Invalid number of arguments."; my ($dir) = @_; return((-d $dir) && (not -l $dir)); } ($#_ == 0) || die "Invalid number of arguments."; my ($server_path) = @_; # look for Zeus servers. if ((isDir("$server_path/webadmin")) || ((-l "$server_path/webadmin") && (-d "$server_path/webadmin/conf/sites")) || ((-l "$server_path/webadmin") && (-d "$server_path/webadmin/conf/virtual_servers/sites"))) { return(locate_nsconfig("$server_path")); } else { # Make sure we match a subdirectory with the name zeus in it, for # completeness. local *ROOT; if (opendir(ROOT,"$server_path")) { my @subfiles = grep { $_ ne "." && $_ ne ".." } readdir(ROOT); closedir(ROOT); my @result; foreach(@subfiles) { if (isDir("$server_path/$_") && (# This which should logically cause a recursion. (-d "$server_path/ns-config") || /^http[ds]-/ )) { push @result,locate_server("$server_path/$_"); } } } } return(); } # locate_nsconfig will be called with the path to the conf/sites subdir # conf/sites contains the files describing the configuration # of the actual configured webservers. # sub locate_nsconfig { ($#_ == 0) || die "Invalid number of arguments."; my ($zeusroot) = @_; my @nsapi_sites; my $vsites_root ; if (-d "$zeusroot/webadmin/conf/sites") { $vsites_root = "$zeusroot/webadmin/conf/sites" ; } elsif ( -d "$zeusroot/webadmin/conf/virtual_servers/sites") { $vsites_root = "$zeusroot/webadmin/conf/virtual_servers/sites" ; } else { return (undef); } local *VSITES_ROOT; if ((-d $vsites_root) && opendir(VSITES_ROOT,"$vsites_root")) { my @vsite_files = grep { ($_ ne ".") && ($_ ne "..") } readdir(VSITES_ROOT); closedir(VSITES_ROOT); foreach my $vsite_file (@vsite_files) { local *VSITE_FILE; my $vsite_path = "$vsites_root/$vsite_file"; if ((-f $vsite_path) && open(VSITE_FILE,"<$vsite_path")) { my $nsapi_enabled; my $nsapi_dir; VSITE_FILE_READ: { foreach() { (m@^\s*modules.nsapi.enabled\s+[yY][eE][sS]@) && do { $nsapi_enabled = 1; }; (m@^\s*modules.nsapi.config_root\s+(.*)@) && do { $nsapi_dir = $1; }; if ($nsapi_enabled && $nsapi_dir) { $nsapi_dir =~ s/%zeushome%/$zeusroot/g; push @nsapi_sites, [$nsapi_dir,$vsite_file]; close(VSITE_FILE); last VSITE_FILE_READ; } } } close(VSITE_FILE); } } } my @result; foreach my $pSiteRecord (@nsapi_sites) { my ($nsapi_dir,$vsite_file) = @$pSiteRecord; # It would probably be better to scan the $nsapi_dir for a matching $vsite_file # (so that we can detect problems, more thoroughly, but ...). local *NSAPI_FILE; foreach my $head ("https","httpd") { foreach my $tail ("config","") { my $path = "$nsapi_dir/$head-$vsite_file/$tail/magnus.conf"; if (-f $path) { push @result, $path; last; } } } } return(@result); } #------------------------------------------------------------------------------ # This method merely discovers as much as it can about the server with the # information pointed to by $pHash, storing this information in the $pHash. #------------------------------------------------------------------------------ # pHash is guaranteed to contain: # conf = # type = zeus sub cache_server { ($#_ == 0) || die "Invalid number of arguments to cache_server."; my ($pServerStats) = (@_); my $bin_dir ; my $bin; my $valid_zeus=0; my $obj_conf = "obj.conf"; # Default to obj.conf, if not specified. my @root = split('/',$pServerStats->{webserver_conf}); pop(@root); while (@root) { my $test_root = join('/',@root); if ((-d "$test_root/web") || (-l "$test_root/web" && -d readlink("$test_root/web"))) { $pServerStats->{webserver_root} = "$test_root"; last; } else { pop(@root); } } unless (exists($pServerStats->{webserver_root})) { return(error("Could not determine Zeus root directory.")); } # This webserver is to be identified as an Zeus webserver. $pServerStats->{webserver_name} = 'Zeus'; # my $server_name = $pServerStats->{webserver_conf}; $server_name =~ s/^(.*)http\S-(.*)\/config(.*)$/$2/; unless (open(CONFIG, "$pServerStats->{webserver_root}/webadmin/conf/sites/$server_name") or open(CONFIG, "$pServerStats->{webserver_root}/webadmin/conf/virtual_servers/sites/$server_name")) { return(error("Could not open Zeus native config file.")); } while() { if (/^\s*port\s+(.*)/i) { $pServerStats->{webserver_port} = $1; } elsif (/^\s*docroot\s+(.*)/i) { $pServerStats->{webserver_docroot} = $1; } elsif (/^\s*ip_name\s+(.*)/i) { $pServerStats->{webserver_realhost} = $1; } } close(CONFIG); $pServerStats->{webserver_vhost} = $server_name; unless (open(MAGNUS, "<$pServerStats->{webserver_conf}")) { return(error("Could not open Zeus NSAPI config file.")); } while() { # zeus magnus.conf files are minimal... # only have the obj.conf info if (/LoadObjects\s(.*)/i) { $obj_conf = $1; } } close(MAGNUS); my $absolute_objconf; if ($obj_conf =~ /^\//) { $absolute_objconf = $obj_conf; } else { $absolute_objconf = "$pServerStats->{webserver_conf}"; $absolute_objconf =~ s/(.*)magnus.conf(.*)$/$1/; $absolute_objconf .= $obj_conf; } $pServerStats->{webserver_obj_conf} = $absolute_objconf; ### Update the mime.types file to refer to the appropriate locations. unless(open(IN, "<$pServerStats->{webserver_obj_conf}")) { return(error("Could not load Object Configuration file")); } my $mime_types = "mime.types"; # Default to mime.types, if not specified. while() { if (/Init\sfn=("?)load-types\1\smime-types=("?)(.*)(\2)/i) { $mime_types = $3; } } close(IN); my $absolute_mime=' '; if ($mime_types =~ /^\//) { $absolute_mime = $mime_types; } else { $absolute_mime = "$pServerStats->{webserver_conf}"; $absolute_mime =~ s/(.*)magnus.conf(.*)$/$1/; $absolute_mime .= $mime_types; } $pServerStats->{webserver_mime_types} = $absolute_mime; unless(open(IN, "<$pServerStats->{webserver_mime_types}")) { return(error("Could not open $pServerStats->{webserver_mime_types}")); } close(IN); # Let us try to get the obj.conf. if (-f $pServerStats->{webserver_conf}) { if (not exists $pServerStats->{webserver_obj_conf}) { return(error("Unable to locate obj.conf \n")); } } if (not exists $pServerStats->{webserver_binary}) { if ((exists $pParameters->{webserver_binary}) && ($pParameters->{webserver_binary} =~ /zeus/i)) { $pServerStats->{webserver_binary} = $pParameters->{webserver_binary}; $bin_dir = dirname($pParameters->{webserver_binary}); $bin = basename($pParameters->{webserver_binary}); } elsif ((-d "$pServerStats->{webserver_root}/web/bin") && (-r "$pServerStats->{webserver_root}/web/bin/zeus.web")) { $pServerStats->{webserver_binary} = "$pServerStats->{webserver_root}/web/bin/zeus.web"; $bin_dir = "$pServerStats->{webserver_root}/web/bin"; $bin = "zeus.web"; } } else { $bin_dir = dirname($pServerStats->{webserver_binary}); $bin = basename($pServerStats->{webserver_binary}); } # Remove any "" encapsulation. foreach(keys %{$pServerStats}) { $pServerStats->{$_} =~ s/\"([^\"]*)\"/$1/; } ### ## if ($debug) { ## trace "bin_dir is $bin_dir \n"; ## trace "bin is $bin \n"; ## } ### use Cwd; if ((-d "$bin_dir") && (-x "$bin_dir/$bin")) { my $cwd = getcwd(); chdir $bin_dir or die "couldn't change to directory $bin_dir"; open ZEUS_BIN, "ZEUSHOME=$pServerStats->{webserver_root}; export ZEUSHOME; cd $bin_dir;./$bin -v |" or die "Unable to detect the Zeus version "; while () { if( /Version\s+([^,]+)/ ) { # If we've got this far then we are 99.95% likely to be Zeus my $valid_zeus = 1; my $v_string = $1; my @versions = split(/\./, $v_string ); my $version = @versions[0]; if( $#versions > 2 ) { # Version 3.3.x $pServerStats->{webserver_version} = "$version.@versions[1]"; $pServerStats->{webserver_release} = "$version.@versions[1] @versions[2]"; $pServerStats->{webserver_major} = "$version"; $pServerStats->{webserver_minor} = "@versions[1]"; } else { # Version 4.xWx # We're going to have to split out @versions[1] to get the # release number, type, and point number @versions[1] =~ /(\d)(.*)/; my $release = $1; my $minor = $2; my $type; my $point ; if( $minor =~ /(\w+)(\d)/ ) { # We've got a point release $type = $1; $minor = $2; } else { # We're the first release - point number is silent 0 $type = $minor; $point = 0; } $pServerStats->{webserver_version} = "$version.$release"; $pServerStats->{webserver_release} = "$version.$release.$minor"; $pServerStats->{webserver_major} = "$version"; $pServerStats->{webserver_minor} = $release; } last ; } } close(ZEUS_BIN); chdir $cwd or die "couldn't change to directory $cwd "; } else { return(error("Unable to obtain version values for the server with this Zeus binary:", "$pServerStats->{webserver_binary}")); } if (not exists $pServerStats->{webserver_version}) { note("The specified webserver_binary=$pServerStats->{webserver_binary} option", "specifies a binary which does not appear to be a Zeus binary. This", "was detected by running '$pServerStats->{webserver_binary} -v' and not", "receiving a result containing the word 'Version'. As a result", "while the install will attempt to continue, this binary assumed to", "correspond with the Web server configuration file (specified", "below) may not be correct:", " $pServerStats->{webserver_conf}"); } ## FIXME,we are yet to add support for Secure Socket Layer webservers $pServerStats->{webserver_https} = "no"; my $vs_start_script; ## starts an individual site my $zeus_start_script; ## starts the zeus webserver (but not its admin site) my $stop_script; if (not exists $pServerStats->{webserver_start_script}) { ### set up virtual site start script if (not -r "$pServerStats->{webserver_root}/$CONST_StartScript" ) { note ("Unable to find the Zeus virtual website start script location at:", " $pServerStats->{webserver_root}/$CONST_StartScript\n"); $vs_start_script = INSTALL::query::user_function ("Enter the path and filename of the Zeus virtual server start script\n", *confirm_existence, "default=none", "invalid_choice="); if ($vs_start_script eq "none") { note("Unable to find the Zeus virtual server start script.", "Skipping this installation."); return (undef); } } else { $vs_start_script="$pServerStats->{webserver_root}/$CONST_StartScript"; } ### set up zeus-toplevel start script if (not -r "$pServerStats->{webserver_root}/$CONST_ZeusStartScript" ) { note ("Unable to find the Zeus top-level start script location at:", " $pServerStats->{webserver_root}/$CONST_ZeusStartScript\n"); $zeus_start_script = INSTALL::query::user_function ("Enter the path and filename of the Zeus top-level Web server start script\n", *confirm_existence, "default=none", "invalid_choice="); if ($zeus_start_script eq "none") { note("Unable to find the Zeus top-level server start script.", "Skipping this installation."); return (undef); } } else { $zeus_start_script="$pServerStats->{webserver_root}/$CONST_ZeusStartScript"; } ### put them together if ( -r "$vs_start_script" && -r "$zeus_start_script" ) { $pServerStats->{webserver_start_script}= "$zeus_start_script start >/dev/null 2>&1; $vs_start_script $pServerStats->{webserver_vhost}"; } } if (not exists $pServerStats->{webserver_stop_script}) { if (not -r "$pServerStats->{webserver_root}/$CONST_StopScript" ) { note ("Unable to find the Zeus stop script location at $pServerStats->{webserver_root}\n"); $stop_script = INSTALL::query::user_function ("Enter the path and filename of the Zeus Web server stop script\n", *confirm_existence, "default=none", "invalid_choice="); if ($stop_script eq "none") { note ("Unable to find the Zeus server stop script.", "Skipping this installation.\n"); return (undef); } $pServerStats->{webserver_stop_script} = "$stop_script"; } else { $pServerStats->{webserver_stop_script}= "$pServerStats->{webserver_root}/$CONST_StopScript"; } } if (-r $pServerStats->{webserver_stop_script}) { $pServerStats->{webserver_stop_script} = "$pServerStats->{webserver_stop_script} $pServerStats->{webserver_vhost}"; } $pServerStats->{webserver_status_script} = "$pGlobals->{asphome}/INSTALL/zeusctl \"binary=$pServerStats->{webserver_binary}\" ". "\"conf=$pServerStats->{webserver_conf}\" \"install_root=$pServerStats->{webserver_root}\" status"; return(1); } ################################################## # Start / Stop Zeus rpm on (X) distribution. ################################################## sub restart_zeus { (@_ == 1) || die "Invalid number of arguments."; my $pServerStats = shift @_; if (exists $pServerStats->{webserver_stop_script} && exists $pServerStats->{webserver_start_script}) { my $result = not system_log($pServerStats->{webserver_stop_script}); INSTALL::common::usleep(50000); $result |= not system_log($pServerStats->{webserver_start_script}); return($result); } else { return(0); } } sub start_zeus { (@_ == 1) || die "Invalid number of arguments."; my $pServerStats = shift @_; if (exists $pServerStats->{webserver_start_script}) { my $result = not system_log($pServerStats->{webserver_start_script}); return($result); } else { return(0); } } sub stop_zeus { (@_ == 1) || die "Invalid number of arguments."; my $pServerStats = shift @_; if (exists $pServerStats->{webserver_stop_script}) { my $result = not system_log($pServerStats->{webserver_stop_script}); INSTALL::common::usleep(50000); return($result); } else { return(0); } } my @CONST_DefaultZeusDirs = ( "/usr/local/zeus", "/usr/zeus", "/usr/local/Zeus", "/usr/Zeus" ); #------------------------------------------------------------------------------ # This method will ask all of the appropriate questions, to properly configure # a Zeus server. This method will not, however, do the actual # installation. The name is a bit misleading, since it in truth only gathers # the information necessary for configuring the server. #------------------------------------------------------------------------------ sub configure_unlisted { sub confirm_valid_zeus { ($#_ == 0) || die "Invalid number of arguments."; my ($dir) = @_; if ($dir eq "none") { report(""); my $answer = INSTALL::query::user ("Would you like to cancel the set-up","terminal_mark=?","y","default=n"); report(""); if ($answer eq "y") { return(1); } else { # Cause a requery. return(undef); } } elsif (not -d $dir) { report("Invalid: ", "The specified dir does not exist."); report(""); # Cause a requery. return(undef); } elsif (not locate_server($dir)) { report("Invalid: ","Unable to locate any Zeus NSAPI servers in that directory."); report(""); # Cause a requery. return(undef); } return(1); } my $server_rootdir; # Try to pick the appropriate zeus directory, if one can be found, otherwise # rever foreach(@CONST_DefaultZeusDirs) { if (-d $_) { $server_rootdir = $_; last; } } if (not $server_rootdir) { $server_rootdir = $CONST_DefaultZeusDirs[0]; } my ($cache_file) = (@_); CONFIGURE_ZEUS: INSTALL::query::user_menu ("Sun Chili!Soft ASP - Zeus Configuration", "To configure Sun Chili!Soft ASP to run with the Zeus Web server, ". "you must enter the root directory of your Zeus installation. ". "A typical installation is located at $server_rootdir. Verify the location ". "of the Zeus server before proceeding with this configuration.\n". " \n". "Note: To exit out of Web server configuration, type 'none' for the\n". " listed option." ); $server_rootdir = INSTALL::query::user_function ("Enter the path name of the Zeus Web server installation \n", *confirm_valid_zeus, "default=$server_rootdir", "invalid_choice="); if ($server_rootdir eq "none") { return(); } else { $server_rootdir = realpath($server_rootdir); my @located_servers = locate_server($server_rootdir); my @pServerHashes; foreach my $located_server (@located_servers) { my $pServerHash = { webserver_conf => $located_server, webserver_type => "zeus" }; if (cache_server($pServerHash)) { push @pServerHashes,$pServerHash; } } return(@pServerHashes); } } #------------------------------------------------------------------------------ # This method merely attempts to take the webserver information given to it # and tries to configure that webserver to work with a generated Sun Chili!Soft # ASP server. The server is generated on the fly. #------------------------------------------------------------------------------ sub configure { my $custom_install = boolean_value($pParameters->{custom_install}); sub detect_supported_versions { my @supported_versions; local *MODULES_DIR; if (opendir(MODULES_DIR,$pGlobals->{module_dir})) { my @subdirs = readdir(MODULES_DIR); closedir(MODULES_DIR); foreach (@subdirs) { if ($CONST_UseZeusVersions) { if ($_ =~ /zeus_([0-9]\.[0-9])/) { push @supported_versions,$1; } } else { if ($_ =~ /zeus/i) { push @supported_versions,$_; } } } return(@supported_versions); } else { error("Unable to read module directory in installation:", " $pGlobals->{module_dir}"); exit(1); } } sub exit_parent { ($#_ == 0) || die "Invalid number of arguments."; my ($pid) = @_; if (interactive) { INSTALL::common::signal_spinner($pid); } else { waitpid($pid,0); } return(undef); } (@_ == 1) || die "Invalid number of arguments."; my $pServerStats = shift @_; (ref($pServerStats)) || die "Invalid argument passed."; my @supported_versions = detect_supported_versions; # Check version support. if ($CONST_UseZeusVersions) { my $quoted_version = quotemeta($pServerStats->{webserver_version}); if ($debug) { print "value of quoted version is $quoted_version\n"; print "version is $pServerStats->{webserver_version} \n"; print "list of supported versions are @supported_versions \n"; note " "; } if (not grep { /$quoted_version/ } @supported_versions) { note("The specified version ($pServerStats->{webserver_version}) of Zeus is not currently", "supported. Sun Chili!Soft ASP will not be configured for this Zeus", "webserver"); report("Press Enter to continue ..."); ; return(undef); } } ########## Check the server_stats for a valid setup. if (not -d $pServerStats->{webserver_root}) { return(error("The specified Web server root '$pServerStats->{webserver_root}' does not exist.")); } if (not -f $pServerStats->{webserver_conf}) { return(error("The specified Web server configuration file '$pServerStats->{webserver_conf}'", "does not exist.")); } if (not -f $pServerStats->{webserver_obj_conf}) { return(error("The specified Web server Object configuration file '$pServerStats->{webserver_obj_conf}", "does not exist.")); } if (not -x "$pServerStats->{webserver_binary}") { return(error("The specified Web server executable ", "'$pServerStats->{webserver_binary}' does not", "exist or is not executable.")); } if ($pServerStats->{webserver_type} !~ /zeus/i) { return(error("Attempting to configure a '$pServerStats->{webserver_type}' server with the", "Zeus NSAPI module.")); } # Now that the configuration appears correct, we should recache the server # with the same information cache_server($pServerStats); ########## If the user wants auto startup of zeus and it's supported ... my $start_zeus = 0; my $supported_autostart = (exists $pServerStats->{webserver_start_script} && exists $pServerStats->{webserver_stop_script}); if ($supported_autostart) { $start_zeus = 1; if (exists $pParameters->{webserver_restart}) { $start_zeus = boolean_value($pParameters->{webserver_restart}); } } ### FIXME: We probably need a more distribution specific section of code here. if (interactive) { if ($supported_autostart && $custom_install) { $start_zeus = INSTALL::query::boolean_default ("Would you like me to restart this Zeus server for you", $start_zeus); } } if (interactive) { print STDERR ("Configuring the $pServerStats->{webserver_name} Web server ... "); } my $pid = fork; if ($pid) { ##########========== Parent ## Update the obj.conf file to refer to the appropriate locations. copy($pServerStats->{webserver_obj_conf},"$pServerStats->{webserver_obj_conf}.pre-chiliasp"); my $dupname = "$pServerStats->{webserver_obj_conf}.chiliasp-install"; copy($pServerStats->{webserver_obj_conf},$dupname); #conf is the main configuration file, which contains the #server informations of this server. unless ((open(IN,"<$dupname")) && (open(OUT,">$pServerStats->{webserver_obj_conf}"))) { # Back out any changes. close(IN); close(OUT); copy("$pServerStats->{webserver_obj_conf}.pre-chiliasp",$pServerStats->{webserver_obj_conf}); unlink($dupname); error("Unable to open $pServerStats->{webserver_obj_conf} for modification.", "Skipping the server Configuration"); # Run cleanup code. return(exit_parent($pid)); } my $inits = 0; my $service = 0; my $casptrans_written = 0; while () { s/\r//; if ((! $inits) && (/^Init/i)) { if ($CONST_UseZeusVersions) { my $major = $pServerStats->{webserver_major}; my $minor = $pServerStats->{webserver_minor}; print OUT qq!Init fn="load-modules" funcs="caspreq,caspinit,casptrans" shlib="$pGlobals->{module_dir}/zeus_$major.$minor/zeus_nsapi_casp2.$pGlobals->{lib_ext}"\nInit fn="caspinit" casplib="$pServerStats->{engine_dir}"\n!; } else { print OUT qq!Init fn="load-modules" funcs="caspreq,caspinit,casptrans" shlib="$pGlobals->{module_dir}/zeus/zeus_nsapi_casp2.$pGlobals->{lib_ext}"\nInit fn="caspinit" casplib="$pServerStats->{engine_dir}"\n!; } $inits = 1; } if (//i .. /<\/Object>/i) { # gotta add a dummy thing here for ASP to pick up the doc root. if (//i) { print OUT "\nNameTrans fn=document-root root=$pServerStats->{webserver_docroot}\n\n\n"; } if (/<\/Object>/i) { if (! $casptrans_written) { print OUT qq@NameTrans fn="casptrans"\n@; $casptrans_written = 1; } } if ((! $service) && (/<\/Object>/i)) { print OUT qq!Service method=(GET|POST) type="chilisoft-internal/active-server-page" fn="caspreq" casplib="$pServerStats->{engine_dir}"\n!; $service = 1; } } print OUT if ((! /Init fn="load-modules" funcs="caspreq,caspinit,casptrans"|Init fn="caspinit"|Service method=\"?\(GET\|POST\).*fn="caspreq"|NameTrans fn="casptrans"|Init fn="load-modules" funcs="chiliasp,chiliaspinit"|Init fn="chiliaspinit"|Service method=\"?\(GET\|POST\).*fn="chiliasp"/i)); } close OUT; close IN; #remove the temporary files. unlink($dupname); ### Now time to proceed with "mime.types" my $dupname1 = "$pServerStats->{webserver_mime_types}.chiliasp-install"; copy($pServerStats->{webserver_mime_types},"$pServerStats->{webserver_mime_types}.pre-chiliasp"); copy($pServerStats->{webserver_mime_types},$dupname1); unless ((open(IN,"<$dupname1")) && (open(OUT,">$pServerStats->{webserver_mime_types}"))) { # Back out any changes. close(IN); close(OUT); copy("$pServerStats->{webserver_mime_types}.pre-chiliasp",$pServerStats->{webserver_mime_types}); unlink($dupname1); error("Unable to modify $pServerStats->{webserver_mime_types} ."); # Run cleanup code. return(exit_parent($pid)); } while () { s/\r//; if (!(/^\s*\#/) && (/exts=(asp|asa)(,|\s)/i)) { print OUT "## by Sun Chili!Soft ASP install: " . $_; } else { print OUT if (!m@type=chilisoft-internal/active-server-page@i); } } print OUT "type=chilisoft-internal/active-server-page\texts=asp,asa\n"; close IN; close OUT; #remove the temporary files. unlink($dupname1); my $restarted = 0; if ($start_zeus) { $restarted = restart_zeus($pServerStats); } exit_parent($pid); if (interactive && (not $restarted)) { print STDERR "\n"; note("For your Web server to function properly, you will need to restart", "it. The configuration file for this Web server is:", " $pServerStats->{webserver_conf}"); report("Press Enter to continue ..."); ; } return(1); } else { ##########========== Child if (interactive) { INSTALL::common::spinner_wait_signal; } exit(0); } } #------------------------------------------------------------------------------ # This method when invoked on information regarding a specific Apache server # will remove any remnants of Chili!Soft ASP from that server, as well as # remove any server, which points to that Apache server. #------------------------------------------------------------------------------ sub uninstall { (@_ == 1) || die "Invalid number of arguments."; my $pServerStats = shift @_; (ref($pServerStats)) || die "Invalid argument passed."; my $retVal = 1; if (-f $pServerStats->{webserver_obj_conf}) { unlink("$pServerStats->{webserver_obj_conf}.post-chiliasp"); copy($pServerStats->{webserver_obj_conf},"$pServerStats->{webserver_obj_conf}.post-chiliasp"); unless (open(IN,"<$pServerStats->{webserver_obj_conf}.post-chiliasp") && open(OUT,">$pServerStats->{webserver_obj_conf}")) { error("Unable to open $pServerStats->{webserver_obj_conf} for modification."); $retVal = 2; } else { ########## Strip any Sun Chili!Soft ASP line from the obj.conf file. ########## Keep track of the PidFile directive. while () { s/\r//; if (!(//i .. /<\/Object>/i)) { print OUT if (!(/Init fn="load-modules" funcs="caspreq,caspinit,casptrans"|Init fn="caspinit"|Service method=\"?\(GET\|POST\).*fn="caspreq"|NameTrans fn="casptrans"|Init fn="load-modules" funcs="chiliasp,chiliaspinit"|Init fn="chiliaspinit"|Service method=\"?\(GET\|POST\).*fn="chiliasp"/i)); } } close OUT; close IN; } } else { error_log("Unable to access the webserver's $pServerStats->{webserver_obj_conf}", "file. This may be a result of the Web server having been removed."); note_display("Unable to properly clean up the $pServerStats->{webserver_obj_conf} file.", "The Web server may have previously been removed."); $retVal = 2; } # Now we have to modify the mime.types files. if (-f $pServerStats->{webserver_mime_types}) { unlink("$pServerStats->{webserver_mime_types}.post-chiliasp"); copy($pServerStats->{webserver_mime_types},"$pServerStats->{webserver_mime_types}.post-chiliasp"); unless (open(IN,"<$pServerStats->{webserver_mime_types}.post-chiliasp") && open(OUT,">$pServerStats->{webserver_mime_types}")) { error("Unable to open $pServerStats->{webserver_mime_types} for modification."); $retVal = 2; } else { ########## Strip any Sun Chili!Soft ASP line from the obj.conf file. while () { s/\r//; if (/^\s*\#\# by Sun Chili!Soft ASP install:\s*(.*)/) { print OUT "$1\n"; } else { print OUT if (!(m@type=chilisoft-internal/active-server-page@i)); } } close OUT; close IN; } } else { error_log("Unable to access the webserver's $pServerStats->{webserver_mime_types}", "file. This may be a result of the Web server having been removed."); note_display("Unable to properly clean up the $pServerStats->{webserver_mime_types} file.", "The Web server may have previously been removed."); $retVal = 2; } if ($retVal == 1) { ########## Restart the webserver as appropriate. my $pidFile = "$pServerStats->{webserver_server_root}/logs/pid"; if ((-f $pidFile) || (exists $pServerStats->{webserver_start_script} && exists $pServerStats->{webserver_stop_script})) { my $answer = "y"; my $restart_zeus = 0; # initialize this to zero. if (exists $pParameters->{webserver_restart}) { $restart_zeus = boolean_value($pParameters->{webserver_restart}); } if (interactive && !$restart_zeus) { $answer = INSTALL::query::user ("Would you like to restart this zeus server", "terminal_mark=?", "default=y", "n"); } my $restarted; if ($answer eq "y") { $restarted = restart_zeus($pServerStats); } if (interactive && (not $restarted)) { note("For your Web server to function properly, you need to restart", "it. The configuration file for this Web server is:", " $pServerStats->{webserver_conf}"); report("Press Enter to continue ..."); ; } } else { note("For your Web server to function properly, you need to restart", "it. The configuration file for this Web server is:", " $pServerStats->{webserver_conf}"); report("Press Enter to continue ..."); ; } } else { note("Unable to restart the $pServerStats->{webserver_name} Web server with configuration file:", " $pServerStats->{webserver_conf}"); } return($retVal); } 1;