home *** CD-ROM | disk | FTP | other *** search
Wrap
# # ASSetup.pm # # Author: Michael Smith (mikes@ActiveState.com) # # Copyright ⌐ 1999 ActiveState Tool Corp., all rights reserved. # ############################################################################### package ASSetup; use PPM; use XML::PPMConfig; use XML::Parser; use Win32::OLE; use Win32::Process; use Data::Dumper; use Win32::Registry; eval('use Win32::Service;'); use constant SERVICE_STARTED => 4; use constant SERVICE_STOPPED => 1; ############################################################################### # ############################################################################### sub ModifyRegValue { my ($path, $data, $action, $duplicate_ok) = @_; my ($root, $path, $value) = ($path =~ m#(.*?)\\(.*)\\(.*)#); $root = ${"main::$root"}; return "Error: invalid Registry root : $root!" unless defined $root; my $key; $root->Open($path, $key) || return "Error: $! !"; my $olddata; my $type; $key->QueryValueEx($value, $type, $olddata) || return "Error: $! !"; if($olddata =~ m#$data# && $action ne 'REPLACE') { unless($duplicate_ok) { return '0'; } } if($action eq 'PREPEND') { $data .= $olddata; } elsif($action eq 'APPEND') { $data = $olddata . $data; } elsif($action eq 'REPLACE') { # Do nothing here } else { return "Error: unknown action : $action"; } $key->SetValueEx($value, 0, $type, $data) || return "Error: $! !"; $key->Close(); return '1'; } ############################################################################### # ############################################################################### sub addDependent { my ($data_file, $dependent) = @_; open(DATA, "<$data_file") or return "Error: reading $data_file! $!"; map($data .= $_, <DATA>); close(DATA); eval($data); return if grep /^$dependent$/i, @$dependents; push (@$dependents, $dependent); my $data = Data::Dumper->Dump( [ $app_name, $is_uninstall_string, \@$path_info, \@$iis_virt_dir, \%$iis_script_map, $ns_config_dir, \%$lines_in_file, \@$directory, \@$file, \@$dependents ], [ "app_name", "is_uninstall_string", "path_info", "iis_virt_dir", "iis_script_map", "ns_config_dir", "lines_in_file", "directory", "file", "dependents" ] ); open(DATA, ">$data_file"); print DATA $data; close(DATA); return; } ############################################################################### # ############################################################################### sub shellExec { system(@_) == 0 or return "Error: Status returned from $_[0] : $?"; my $obj; my $appname = shift; my $cmdline = $appname . ' ' . join(' ', @_); my $iflags = 0; my $cflags = NORMAL_PRIORITY_CLASS; my $curdir = '.'; Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir) || return 'Error: ' . Win32::FormatMessage( Win32::GetLastError() ); $obj->Wait(INFINITE); my $exit_code; $obj->GetExitCode($exit_code); return "Error: $appname exited with code: $exit_code" if $exit_code != 0; } ############################################################################### # ############################################################################### sub EvalScript { my ($script_name) = shift; local (@ARGV) = @_; do $script_name; return "Error: $@" if $@ ne ''; } ############################################################################### # ############################################################################### sub StopService { return if Win32::IsWin95; my $service = shift; my $status = {}; my $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } if($status->{'CurrentState'} != SERVICE_STOPPED) { $rv = Win32::Service::StopService('', $service); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } while($status->{'CurrentState'} != SERVICE_STOPPED) { sleep(5); $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } } } return; } ############################################################################### # ############################################################################### sub StartService { return if Win32::IsWin95; my $service = shift; my $status = {}; my $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } if($status->{'CurrentState'} != SERVICE_STARTED) { $rv = Win32::Service::StartService('', $service); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } while($status->{'CurrentState'} != SERVICE_STARTED) { sleep(5); $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { return 'Error: ' . Win32::FormatMessage(Win32::GetLastError()); } } } return; } ############################################################################### # Config.pm values to propogate when doing an upgrade installation ############################################################################### my @propagateThese = qw( ar archlib archlibexp awk bash bin binexp bison byacc cat cc cf_by cf_email cp cryptlib csh date echo egrep emacs expr find flex full_csh full_sed gccversion glibpth gzip incpath inews installarchlib installbin installhtmldir installhtmlhelpdir installman1dir installman3dir installprivlib installscript installsitearch installsitelib ksh ld lddlflags ldflags less libc libpth ln lns loincpth lolibpth lp lpr ls mail mailx make man1dir man1direxp man3dir man3direxp mkdir more mv mydomain myhostname myuname pager perlpath prefix prefixexp privlib privlibexp rm rmail scriptdir scriptdirexp sed sendmail sh sitearch sitearchexp sitelib sitelibexp touch tr usrinc vi xlibpth zcat zip ); ############################################################################### # ############################################################################### sub mergeConfig { my $file1 = shift; my $file2 = shift; open(FILE1, "<$file1") || return "Error: Could not open file $file1 : $!"; my $foundConfigBegin = 0; my $foundConfigEnd = 0; my %Config1 = (); while(<FILE1>) { chomp; if (!$foundConfigBegin && /^my \$config_sh = <<'!END!';$/) { $foundConfigBegin = 1; next; } elsif (!$foundConfigEnd && /^!END!$/) { last; } next if(!$foundConfigBegin); my ($name, $value) = split(/=/, $_, 2); if(grep(/$name/, @propagateThese)) { $Config1{$name} = $value; } } close(FILE1); open(FILE2, "+<$file2") || return "Error: Could not open file $file2 : $!"; $foundConfigBegin = 0; $foundConfigEnd = 0; my @Config2 = (); while(<FILE2>) { my $line = $_; chomp($line); if (!$foundConfigBegin && $line =~ /^my \$config_sh = <<'!END!';$/) { $foundConfigBegin = 1; } elsif (!$foundConfigEnd && $line =~ /^!END!$/) { $foundConfigEnd = 1; } elsif ($foundConfigBegin && !$foundConfigEnd) { my ($name, $value) = split(/=/, $line, 2); if(exists $Config1{$name} && length($Config1{$name}) > 0) { $line = "$name=$Config1{$name}"; } } push(@Config2, $line . "\n"); } truncate(FILE2, 0); seek(FILE2, 0, 0); print FILE2 (@Config2); close(FILE2); return; } ############################################################################### # ############################################################################### sub mergePPMConfig { my $file1 = shift; my $file2 = shift; my $parser = new XML::Parser(Style => 'Objects', Pkg => 'XML::PPMConfig'); my $Config1 = $parser->parsefile($file1); my $Config2 = $parser->parsefile($file2); my $i = 0; foreach my $elem (@{$Config1->[0]->{Kids}}) { if((ref $elem) =~ /.*::PACKAGE$/) { if (! existsInConfig('PACKAGE', $elem->{NAME}, $Config2)) { splice(@{$Config2->[0]->{Kids}}, $i, 0, $elem); } } ++$i; } open(FILE, ">$file2") || return "Error: Could not open $file2 : $!"; select(FILE); my $Config_ref = bless($Config2->[0], "XML::PPMConfig::PPMCONFIG"); $Config_ref->output(); close(FILE); return; } ############################################################################### # ############################################################################### sub existsInConfig { my $element = shift; my $name = shift; my $config = shift; foreach my $elem (@{$config->[0]->{Kids}}) { return 1 if ((ref $elem) =~ /.*::$element$/ && $elem->{NAME} eq $name); } return 0; } # # Uninstall.pm # # Author: Michael Smith (mikes@ActiveState.com) # # Copyright ⌐ 1998 ActiveState Tool Corp., all rights reserved. # ############################################################################### package ASSetup::Uninstall; # # Uninstall configuration # ############################################################################### my $data_file = 'p_uninst.dat'; my $data_path = ''; my $app_name = ''; # # Things we need to track # ############################################################################### # InstallShiel uninstall data file $is_uninstall_string; # Directories added to the PATH environment variable @path_info; # IIS4 configuration information @iis_virt_dir; %iis_script_map; # Netscape configuration information $ns_config_dir; %lines_in_file; # Additional files and directories @directory; @file; # # Function defininitions # ############################################################################### sub LoadData { return unless -e "$data_path/$data_file"; return unless open(FILE, "< $data_path/$data_file"); local $/ = undef; my $data = <FILE>; close(FILE); eval($data); } # Set_DataPath sub Set_DataPath { $data_path = $_[0]; } # Set_AppName sub Set_AppName { $app_name = $_[0]; } # Get_DataFile sub Get_DataFile { return "$data_path/$data_file"; } # Set_IS_UninstallString sub Set_IS_UninstallString { $is_uninstall_string = $_[0]; } # Add_PathInfo sub Add_PathInfo { push(@path_info, $_[0]); } # Add_IIS_VirtDir sub Add_IIS_VirtDir { push(@iis_virt_dir, $_[0]); } # Add_IIS_ScriptMap sub Add_IIS_ScriptMap { my $virt_dir = $_[0]; my $file_ext = $_[1]; $virt_dir = '.' if $virt_dir eq ''; push(@{$iis_script_map{$virt_dir}}, $file_ext); } # Set_NS_ConfigDir sub Set_NS_ConfigDir { $ns_config_dir = $_[0]; } # Add_Line sub Add_Line { my ($file, $line) = @_; $file = lc($file); push(@{$lines_in_file{$file}}, $line); } # Add_File sub Add_File { push(@file, $_[0]); } # Add_Directory sub Add_Directory { push(@directory, $_[0]); } # Write_Data sub Write_Data { my $data = Data::Dumper->Dump( [ $app_name, $is_uninstall_string, \@path_info, \@iis_virt_dir, \%iis_script_map, $ns_config_dir, \%lines_in_file, \@directory, \@file ], [qw( app_name is_uninstall_string path_info iis_virt_dir iis_script_map ns_config_dir lines_in_file directory file )] ); open(DATA, ">$data_path/$data_file"); print DATA $data; close(DATA); } ############################################################################### # Company : ActiveState Tool Corp. # Author : James A. Snyder ( James@ActiveState.com ) # Date : 7/11/98 # Copyright ⌐ 1998 ActiveState Tool Corp., all rights reserved. # ############################################################################### # MetabaseConfig.pm package ASSetup::MetabaseConfig; ############################################################################### # ScriptMap flags sub MD_SCRIPTMAPFLAG_SCRIPT_ENGINE{1}; sub MD_SCRIPTMAPFLAG_CHECK_PATH_INFO{4}; ############################################################################### # Access Permission Flags sub MD_ACCESS_READ { 0x00000001 }; # // Allow for Read sub MD_ACCESS_WRITE { 0x00000002 }; # // Allow for Write sub MD_ACCESS_EXECUTE { 0x00000004 }; # // Allow for Execute sub MD_ACCESS_SCRIPT { 0x00000200 }; # // Allow for Script execution sub MD_ACCESS_NO_REMOTE_WRITE { 0x00000400 }; # // Local host access only sub MD_ACCESS_NO_REMOTE_READ { 0x00001000 }; # // Local host access only sub MD_ACCESS_NO_REMOTE_EXECUTE { 0x00002000 }; # // Local host access only sub MD_ACCESS_NO_REMOTE_SCRIPT { 0x00004000 }; # // Local host access only ############################################################################### $ASSetup::MetabaseConfig::LogObject = undef; # Set the reference to the Log object sub SetLogObject { $ASSetup::MetabaseConfig::LogObject = shift; if(!$ASSetup::MetabaseConfig::LogObject->isa("Log")) { $ASSetup::MetabaseConfig::LogObject = undef; } } $ASSetup::MetabaseConfig::StatusStarted = 4; $ASSetup::MetabaseConfig::StatusStopped = 1; sub StopIISAdmin { my $output = `net stop IISAdmin /y`; if($?) { return "Error: oops there was a problem stopping the IISAdmin service\n"; } $output = `net start`; my @output = split($/, $output); my $grep_results = grep(/IIS Admin Service/, @output); if($grep_results) { return "Error: oops we thought we stopped the IISAdmin service when we didn't\n"; } # MetabaseConfig::StopService('W3SVC') || return "Error stopping the W3SVC service"; # MetabaseConfig::StopService('MSFTPSVC') || return "Error stopping the MSFTPSVC service"; # MetabaseConfig::StopService('IISADMIN') || return "Error stopping the IISADMIN service"; # my $result = `net stop IISADMIN /y`; } sub StartIISAdmin { MetabaseConfig::StartService('IISADMIN') || return "Error starting the IISADMIN service"; MetabaseConfig::StartService('W3SVC') || return "Error starting the W3SVC service"; MetabaseConfig::StartService('MSFTPSVC') || return "Error starting the MSFTPSVC service"; # my $result = `net start IISADMIN /y`; # $result = `net start W3SVC /y`; # $result = `net start MSFTPSVC /y`; } ############################################################################### # StopIISAdmin(); sub StopService { my $service = shift; my $status = {}; my $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { print Win32::FormatMessage(Win32::GetLastError()), "\n"; $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetStatus of $service service in first attempt MetabaseConfig::StopIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return 1; } if($status->{'CurrentState'} != $ASSetup::MetabaseConfig::StatusStopped) { $rv = Win32::Service::StopService('', $service); if(!$rv) { print Win32::FormatMessage(Win32::GetLastError()), "\n"; $ASSetup::MetabaseConfig::LogObject->ERROR("Could not stop $service service in MetabaseConfig::StopIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return $rv; } while($status->{'CurrentState'} != $ASSetup::MetabaseConfig::StatusStopped) { sleep(10); $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { print Win32::FormatMessage(Win32::GetLastError()), "\n"; $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetStatus of $service service in MetabaseConfig::StopIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return $rv; } } } $ASSetup::MetabaseConfig::LogObject->TRACE("$service service is stopped in MetabaseConfig::StopIISAdmin") if $ASSetup::MetabaseConfig::LogObject; return 1; } ############################################################################### # StartIISAdmin(); sub StartService { my $service = shift; my $status = {}; my $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetStatus of $service service in first attempt MetabaseConfig::StartIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return 1; } if($status->{'CurrentState'} != $ASSetup::MetabaseConfig::StatusStarted) { $rv = Win32::Service::StartService('', $service); if(!$rv) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not start $service service in MetabaseConfig::StartIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return $rv; } while($status->{'CurrentState'} != $ASSetup::MetabaseConfig::StatusStarted) { sleep(5); $rv = Win32::Service::GetStatus('', $service, $status); if(!$rv) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetStatus of $service service in MetabaseConfig::StartIISAdmin: $!") if $ASSetup::MetabaseConfig::LogObject; return $rv; } } } $ASSetup::MetabaseConfig::LogObject->TRACE("$service service is started in MetabaseConfig::StartIISAdmin") if $ASSetup::MetabaseConfig::LogObject; return 1; } @ASSetup::MetabaseConfig::ServerStash = (); ############################################################################### # StashRunningServers() sub StashRunningServers { my $index = 1; my $path = 'IIS://localhost/W3SVC/'; my $testPath = $path . $index; my $server; $ASSetup::MetabaseConfig::LogObject->TRACE("Stashing running web servers in MetabaseConfig::StashRunningServers") if $ASSetup::MetabaseConfig::LogObject; while ( ($server = Win32::OLE->GetObject($testPath)) ) { $ASSetup::MetabaseConfig::ServerStash[$index] = ($server->Status() == 2); $index++; $testPath = $path . $index; } } ############################################################################### # StartStashedServers() sub StartStashedServers { my $index = 1; my $path = 'IIS://localhost/W3SVC/'; my $testPath = $path . $index; my $server; my $wasStarted; $ASSetup::MetabaseConfig::LogObject->TRACE("Starting stashed web servers MetabaseConfig::StartStashedServers") if $ASSetup::MetabaseConfig::LogObject; foreach $wasStarted (@ASSetup::MetabaseConfig::ServerStash) { if($wasStarted == 1) { $server = Win32::OLE->GetObject($testPath); if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($testPath) in MetabaseConfig::StartStashedServers: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; } else { $server->Start(); } } $index++; $testPath = $path . $index; } } ############################################################################### # StartWWW( $dwWebServerID ); sub StartWWW { my $serverID = $_[0]; my $path = 'IIS://localhost/W3SVC/' . $serverID; my $server = Win32::OLE->GetObject($path); $ASSetup::MetabaseConfig::LogObject->TRACE("Starting WWWServer: $path") if $ASSetup::MetabaseConfig::LogObject; if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($path) in MetabaseConfig::StartWWW: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return undef; } $server->Start(); } ############################################################################### # StopWWW( $dwWebServerID ); sub StopWWW { my $serverID = $_[0]; my $path = 'IIS://localhost/W3SVC/' . $serverID; my $server = Win32::OLE->GetObject($path); $ASSetup::MetabaseConfig::LogObject->TRACE("Stopping WWWServer: $path") if $ASSetup::MetabaseConfig::LogObject; if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($path) in MetabaseConfig::StopWWW: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return undef; } $server->Stop(); } ############################################################################### # $arrayRef = EnumWebServers(); sub EnumWebServers { my $index = 1; my $path = 'IIS://localhost/W3SVC/'; my $testPath = $path . $index; my $server; my @webServers = (); while ( ($server=Win32::OLE->GetObject($testPath)) ) { $webServers[$index] = $server->{ServerComment}; $index++; $testPath = $path . $index; } return \@webServers; } ############################################################################### # GetFileExtMapping($dwServerID, $szVirDir, $szFileExt) sub GetFileExtMapping { if( @_ < 3 ) { # die "Not enough Parameters for GetFileExtMapping()\n"; } my $server = ''; my $szVirDirPath = ''; my $dwServerID = shift; my $szVirDir = shift; my $szFileExt = shift; my $scriptMap = ''; # Create string that contains the Path to our Virutal directory or the WebServer's Root $szVirDirPath = 'IIS://localhost/W3SVC/' . $dwServerID . '/ROOT'; $ASSetup::MetabaseConfig::LogObject->TRACE("Getting file extension mapping: $szFileExt") if $ASSetup::MetabaseConfig::LogObject; if( length($szVirDir) ) { $szVirDirPath = $szVirDirPath . "/" . $szVirDir; } # Get the IIsVirtualDir Automation Object $server = Win32::OLE->GetObject($szVirDirPath); if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($szVirDirPath) in MetabaseConfig::GetFileExtMapping: " . Win32::OLE->LastError) if $ASSetup::MetabaseConfig::LogObject; return; } foreach $scriptMap (@{$server->{ScriptMaps}}) { if($scriptMap =~ /^$szFileExt,/i) { return $scriptMap; } } } ############################################################################### # RemoveFileExtMapping($dwServerID, $szVirDir, $szFileExt) sub RemoveFileExtMapping { if( @_ < 3 ) { # die "Not enough Parameters for AddFileExtMapping()\n"; } my $szVirDirPath = ''; my @newScriptMap = (); my $dwServerID = shift; my $szVirDir = shift; my $szFileExt = shift; my $virDir; my $ScriptMap = ''; if(GetFileExtMapping($dwServerID, $szVirDir, $szFileExt) eq '') { return 1; } # Create string that contains the Path to our Virutal directory or the WebServer's Root $szVirDirPath = 'IIS://localhost/W3SVC/' . $dwServerID . '/ROOT'; if( length($szVirDir) ) { $szVirDirPath = $szVirDirPath . "/" . $szVirDir; } # Get the IIsVirtualDir Automation Object $virDir = Win32::OLE->GetObject($szVirDirPath); if(!$virDir) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($szVirDirPath) in MetabaseConfig::RemoveFileExtMapping: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return; } $ASSetup::MetabaseConfig::LogObject->TRACE("Removing file extension mapping: $szFileExt") if $ASSetup::MetabaseConfig::LogObject; foreach $ScriptMap (@{$virDir->{ScriptMaps}}) { if($ScriptMap !~ /^$szFileExt,/i) { push(@newScriptMap, $ScriptMap); } } # set the ScriptsMaps property to our new script map array $virDir->{ScriptMaps} = \@newScriptMap; # Save the new script mappings $virDir->SetInfo(); } ############################################################################### # AddFileExtMapping($dwServerID, $szVirDir, $szFileExt, $lpszExec, $dwFlags, $szMethodExclusions) sub AddFileExtMapping { if( @_ < 6 ) { # die "Not enough Parameters for AddFileExtMapping()\n"; } my $server = ''; my $szVirDirPath = ''; my $scriptMapping = ''; my @newScriptMap = (); my $dwServerID = shift; my $szVirDir = shift; my $szFileExt = shift; my $szExecPath = shift; my $dwFlags = shift; my $szMethodExc = shift; if(GetFileExtMapping($dwServerID, $szVirDir, $szFileExt) ne '') { return 1; } # Create string that contains the Path to our Virutal directory or the WebServer's Root $szVirDirPath = 'IIS://localhost/W3SVC/' . $dwServerID . '/ROOT'; if( length($szVirDir) ) { $szVirDirPath = $szVirDirPath . "/" . $szVirDir; } # Get the IIsVirtualDir Automation Object $server = Win32::OLE->GetObject($szVirDirPath); if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($szVirDirPath) in MetabaseConfig::AddFileExtMapping: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return; } # create our new script mapping entry $scriptMapping = "$szFileExt,$szExecPath,$dwFlags"; # make sure the length of szMethodExc is greater than 2 before adding szMethodExc to the script mapping if( length($szMethodExc) > 2 ) { $scriptMapping = $scriptMapping . ",$szMethodExc"; } $ASSetup::MetabaseConfig::LogObject->TRACE("Adding file extension mapping: $scriptMapping") if $ASSetup::MetabaseConfig::LogObject; @newScriptMap = @{$server->{ScriptMaps}}; push(@newScriptMap, $scriptMapping); $server->{ScriptMaps} = \@newScriptMap; # Save the new script mappings $server->SetInfo(); } ############################################################################### # CreateVirDir( $dwServerID, $szPath, $szName, $dwAccessPerm, $bEnableDirBrowse, $bAppRoot); sub CreateVirDir { if( @_ < 6 ) { # die "Not enough Parameters for CreateVirDir()\n"; } # Local Variables my $serverPath; my $server; my $virDir; my $dwServerID = shift; my $szPath = shift; my $szName = shift; my $dwAccessPerm = shift; my $bEnableDirBrowse = shift; my $bAppRoot = shift; if($szPath eq "" || $szName eq "") { die "Incorrect Parameter to CreateVirDir() ...\n"; } # Create string that contains the Path to our Webserver's Root $serverPath = 'IIS://localhost/W3SVC/' . $dwServerID . '/Root'; $ASSetup::MetabaseConfig::LogObject->TRACE("Creating virtual directory: $szName") if $ASSetup::MetabaseConfig::LogObject; # Get the IIsWebServer Automation Object $server = Win32::OLE->GetObject($serverPath); if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($serverPath) in MetabaseConfig::CreateVirDir: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return; } # Create Our Virutual Directory or get it if it already exists $virDir = $server->Create('IIsWebVirtualDir', $szName); if( not UNIVERSAL::isa($virDir, 'Win32::OLE') ) { $ASSetup::MetabaseConfig::LogObject->ERROR("Did not create IIsWebVirtualDir object in MetabaseConfig::CreateVirDir: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; $virDir = $server->GetObject('IIsWebVirtualDir', $szName); if(!$virDir) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($szName) in MetabaseConfig::CreateVirDir: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return; } } $virDir->{Path} = $szPath; $virDir->{AppFriendlyName} = $szName; $virDir->{EnableDirBrowsing} = $bEnableDirBrowse; $virDir->{AccessRead} = $dwAccessPerm & MD_ACCESS_READ; $virDir->{AccessWrite} = $dwAccessPerm & MD_ACCESS_WRITE; $virDir->{AccessExecute} = $dwAccessPerm & MD_ACCESS_EXECUTE; $virDir->{AccessScript} = $dwAccessPerm & MD_ACCESS_SCRIPT; $virDir->{AccessNoRemoteRead} = $dwAccessPerm & MD_ACCESS_NO_REMOTE_READ; $virDir->{AccessNoRemoteScript} = $dwAccessPerm & MD_ACCESS_NO_REMOTE_SCRIPT; $virDir->{AccessNoRemoteWrite} = $dwAccessPerm & MD_ACCESS_NO_REMOTE_WRITE; $virDir->{AccessNoRemoteExecute} = $dwAccessPerm & MD_ACCESS_NO_REMOTE_EXECUTE; $virDir->AppCreate($bAppRoot); $virDir->SetInfo(); } ############################################################################### # DeleteVirDir( $dwServerID, $szVirDir ); sub DeleteVirDir { my $dwServerID = $_[0]; my $szVirDir = $_[1]; my $szPath = ''; my $server = ''; if($dwServerID eq "" || $szVirDir eq "") { # die "Incorrect Parameter to DeleteVirDir() ...\n"; } # Create string that contains the Path to our Webserver's Root $szPath = 'IIS://localhost/W3SVC/' . $dwServerID . '/Root'; $ASSetup::MetabaseConfig::LogObject->TRACE("Deleting virtual directory: $szPath") if $ASSetup::MetabaseConfig::LogObject; # Get the IIsWebServer Automation Object $server = Win32::OLE->GetObject($szPath); if(!$server) { $ASSetup::MetabaseConfig::LogObject->ERROR("Could not GetObject($szPath) in MetabaseConfig::DeleteVirDir: " . Win32::OLE->LastError()) if $ASSetup::MetabaseConfig::LogObject; return; } $server->Delete( "IIsWebVirtualDir", $szVirDir ); $server->SetInfo(); } ############################################################################### # ############################################################################### package ASSetup::TR; my %trans_table = (); sub add_translation { $trans_table{$_[0]} = [ $_[1], $_[2] ]; return 1; } sub reset_trans_table { %trans_table = (); return 1; } sub trans { my $file = shift; my @converted = (); open(FH, "<$file") || die "Could not open $file: $!\n"; while(<FH>) { foreach my $key (keys %trans_table) { if($trans_table{$key}->[1]) { s/$key/$trans_table{$key}->[0]/eeg; } else { s/$key/$trans_table{$key}->[0]/eg; } } push(@converted, $_); } close(FH); chmod(0777, $file); unlink($file); open(FH, ">$file") || die "Could not open $file: $!\n"; print(FH @converted); close(FH); return 1; } 1;