renaming files and removing dead code

This commit is contained in:
Adrian Green 2015-07-08 17:30:50 -07:00
Родитель 8522b8993e
Коммит 5f3bb57a2e
9 изменённых файлов: 52 добавлений и 141 удалений

Просмотреть файл

@ -10,7 +10,7 @@ my $errorLogFile ; #Log file name
my $LocalFileName; #Renamed file name of configuration file
my $SESSIONFILELANDLE; #File handle for session file
my $migrationStatus; #To indicate the wizard is running in FRESHRUN mode or RECOVERY
my $logFilereturn; #RETURN VALUE for the file access methods in wsmk_informationLog
my $logFilereturn; #RETURN VALUE for the file access methods in aamt_informationLog
my $parseSuccess ; #To run in the recovery mode, the output of auth_parseRecovery file
my $startTime; #Migration start time for logging
my $fileret;
@ -37,8 +37,8 @@ my $REC_MY_NAME_VIRTUAL_HOST ='[NAME_VIRTUAL_HOST]' ;
################################################################################
sub auth_main
{
ui_clearScreen(); #used to clear screen defined in wsmk_userinterface.pm file
ui_Title(); #used for title of the migartion kit defined in wsmk_userinterface.pm file
ui_clearScreen(); #used to clear screen defined in aamt_userinterface.pm file
ui_Title(); #used for title of the migartion kit defined in aamt_userinterface.pm file
ui_printBanner();
&ilog_print(1,TITLE_SESSION_NAME); #To display title pertaining to session name
($tempretval,$sessionName)=auth_inputSessionName(); #user input "session name" for migration

Просмотреть файл

@ -1,5 +1,5 @@
#---------------------------------------------------------------------------------------------------------
#Script Name : wsmk_constants.pm
#Script Name : aamt_constants.pm
#Description : Package is used to define the strings that would be used by the AIISMT wizard
#-----------------------------------------------------------------------------------------------
@ -73,7 +73,7 @@ use constant M => "Machine Address cannot have
#*****************************************************************************#
# The Following Constants are used in naming the files #
#*****************************************************************************#
use constant AMW => "wsmk_";
use constant AMW => "aamt_";
use constant FILE_RECOVERY => "_Recovery.txt";
use constant FILE_STATUS => "_Status.htm";
use constant FILE_LOG => "_Log.htm";
@ -87,18 +87,18 @@ use constant FILE_SITES => "_sites.txt";
use constant FILE_IISCONFIG => "_config.xml";
use constant FILE_USERLIST => "_userlist.txt";
use constant FILE_ACL => "_acl.txt";
use constant FILE_TARGET_INFO => "wsmk_target_info.txt";
use constant FILE_TARGET_FPSE => "wsmk_target_fpse.vbs";
use constant FILE_TARGET_OVERALL => "wsmk_wrt_overall_target.wsf";
use constant FILE_TARGET_ACL => "wsmk_wrt_acl.vbs";
use constant FILE_TARGET_CREATEUSER => "wsmk_wrt_createuser.vbs";
use constant FILE_TARGET_IMPORT => "wsmk_wrt_import.vbs";
use constant FILE_TARGET_SCRIPTS => "wsmk_iis_scripts.vbs";
use constant FILE_TARGET_INFORMATIONLOG => "wsmk_informationLog.vbs";
use constant FILE_TARGET_CONSTANTS => "wsmk_wrt_constants.vbs";
use constant FILE_TARGET_UTILITIES => "wsmk_wrt_utilities.vbs";
use constant FILE_TARGET_VERIFY => "wsmk_verifier_verifytarget.vbs";
use constant FILE_PERLPRESENT => "WSMK_PERLPRESENT.BAT";
use constant FILE_TARGET_INFO => "aamt_target_info.txt";
use constant FILE_TARGET_FPSE => "aamt_target_fpse.vbs";
use constant FILE_TARGET_OVERALL => "aamt_wrt_overall_target.wsf";
use constant FILE_TARGET_ACL => "aamt_wrt_acl.vbs";
use constant FILE_TARGET_CREATEUSER => "aamt_wrt_createuser.vbs";
use constant FILE_TARGET_IMPORT => "aamt_wrt_import.vbs";
use constant FILE_TARGET_SCRIPTS => "aamt_iis_scripts.vbs";
use constant FILE_TARGET_INFORMATIONLOG => "aamt_informationLog.vbs";
use constant FILE_TARGET_CONSTANTS => "aamt_wrt_constants.vbs";
use constant FILE_TARGET_UTILITIES => "aamt_wrt_utilities.vbs";
use constant FILE_TARGET_VERIFY => "aamt_verifier_verifytarget.vbs";
use constant FILE_PERLPRESENT => "AAMT_PERLPRESENT.BAT";
use constant FILE_TARGET_BATCHFILE => "AIISMT_TARGET.BAT";
use constant FILE_TARGET_VERIFY_BAT => "AIISMT_VERIFY.BAT";
@ -449,7 +449,7 @@ use constant FILE_WRITE => 2;
use constant FILE_APPEND => 3;
use constant FILE_WRITE_EX => 4;
use constant FILE_READ_EX => 5;
use constant WSMK_ERR_FILEOPEN_FAILED => "File could not be opened";
use constant AAMT_ERR_FILEOPEN_FAILED => "File could not be opened";
use constant RECOVERY_MODE_0 => "FRESHRUN";
use constant RECOVERY_MODE_1 => "WSMKREC1";
use constant RECOVERY_MODE_2 => "WSMKREC2";

Просмотреть файл

@ -1,13 +1,13 @@
#----------------------------------------------------------------------------------------------
#Script Name : wsmk_informationLog.pm
#Script Name : aamt_informationLog.pm
#Description : Package is used to log data supplied by individual methods in
# the specified files.
#-----------------------------------------------------------------------------------------------
# include external packages
use strict;
use wsmk_constants;
use aamt_constants;
use IO::File;
use wsmk_utilityFunctions;
use aamt_utilityFunctions;
my $globSessionName;
my $iSpin = 1;

Просмотреть файл

@ -1,14 +1,14 @@
#-------------------------------------------------------------------------
# Script Name : wsmk_parse.pm
# Script Name : aamt_parse.pm
#
# Description : Pre-Parses the apache config files and accepts the
# user inputs requiered for the migration.
# Also generates Recovery Info.
#-------------------------------------------------------------------------
use strict;
use wsmk_constants;
use wsmk_informationLog;
use wsmk_utilityFunctions;
use aamt_constants;
use aamt_informationLog;
use aamt_utilityFunctions;
#-------------------------------------------------------------------------
# Global variables used by this module
my $strSessionFolder; # Path at which all files pertaining to the current

Просмотреть файл

@ -14,7 +14,7 @@
#######################################################################################################################
use strict;
use xml::doc;
use wsmk_utilityFunctions;
use aamt_utilityFunctions;
use JSON;
use Digest::MD5 qw(md5_hex);
use LWP::UserAgent;
@ -163,7 +163,6 @@ sub pars_CreateReadinessReport
$rComputername =~ s/\n//g;
my $login = getlogin || getpwuid($<) || "Kilroy";
my $guid = &genGUID($rComputername.$login);
# todo: write to file
my %rServer = ();
my %rServers = ();
my %rServers2 = ();
@ -218,7 +217,6 @@ sub pars_CreateReadinessReport
}
$json_text = encode_json ( \@rSites );
my %appPool = ("Name"=>"DefaultLinuxAppPool","Enable32BitOn64"=>"false","IsClassicMode"=>"false","NetFxVersion"=>"4");
my @appPools = ();
$appPools[0] = \%appPool;
@ -558,31 +556,9 @@ sub pars_PublishSite
elsif ($strYesOrNo=~/^\s*[Yy]\s*$/)
{
mkdir "$workingFolder/wwwroot";
my @filesToCopy;
# @files = File::Find::Rule->file()
# ->name("*config*.php")
# ->extras({ follow => 1 })
# ->in($documentRoot);
my @filesToCopy;
my $lineMatch = qr/define.*'DB_NAME'|define.*'DB_USER'|define.*'DB_PASSWORD'|define.*'DB_HOST'|define.*'WP_CONTENT_DIR'/;
&getConfigFiles($documentRoot, $lineMatch, $workingFolder, \@files);
# for my $phpFile (@files)
# {
# open my $fh, '<', $phpFile or die "Failed to open $_: $!";
# my $found = FALSE;
# while (my $line = <$fh>)
# {
# if ($line =~ /define.*'DB_NAME'/ || $line =~ /define.*'DB_USER'/ || $line =~ /define.*'DB_PASSWORD'/ || $line =~ /define.*'DB_HOST'/ || $line =~ /define.*'WP_CONTENT_DIR'/)
# {
# my $newName = $phpFile;
# my $find = quotemeta $documentRoot; # escape regex
# $newName =~ s/$find//g;
# File::Copy::copy($phpFile, "$workingFolder/wwwroot/${newName}_copy");
# last;
# }
# }
# }
&getConfigFiles($documentRoot, $lineMatch, $workingFolder, \@files);
@files = File::Find::Rule->file()
->name("*_copy")
->in("$workingFolder/wwwroot");
@ -620,7 +596,6 @@ sub pars_PublishSite
close $out;
if (!$settingsInserted)
{
# print $out $settingsLine;
# delete the file
unlink $outFile;
}
@ -654,8 +629,7 @@ sub pars_PublishSite
# settings.php is probably a common name and site detection should be improved
$siteType = "drupal";
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: Searching for Drupal site found\n"); }
my $originalConfig = @files[0];
# ilog_print(1, "php read_drupal_settings.php $originalConfig $workingFolder/config-out.txt;");
my $originalConfig = @files[0];
`php read_drupal_settings.php "$originalConfig" "$workingFolder/config-out.txt";`;
open my $originalConfig, '<', "$workingFolder/config-out.txt" or die "Can't read config-out.txt: $!";
while (my $line = <$originalConfig>)
@ -698,61 +672,9 @@ sub pars_PublishSite
elsif ($strYesOrNo=~/^\s*[Yy]\s*$/)
{
mkdir "$workingFolder/wwwroot";
my @filesToCopy;
# @files = File::Find::Rule->file()
# ->name("*.php")
# ->in($documentRoot);
my @filesToCopy;
my $lineMatch = qr/databases.*'default'.*'default'/;
&getConfigFiles($documentRoot, $lineMatch, $workingFolder, \@files);
# for my $phpFile (@files)
# {
# open my $fh, '<', $phpFile or die "Failed to open $_: $!";
# my $found = FALSE;
# my $filecopied = FALSE;
# while (my $line = <$fh>)
# {
# if ($line =~ /databases.*'default'.*'default'/ && !$filecopied)
# {
# # resolve symlinks
# my $documentRoot2 = quotemeta($documentRoot);
# if ($phpFile !~ /$documentRoot2/)
# {
# my $baseFile = basename($phpFile);
# if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: Relocating phpFile: $phpFile (basename: $baseFile | documentRoot: $documentRoot)\n"); }
# # it is not under documentRoot, let's try to locate it under document root.
# my @docrootfiles = File::Find::Rule->file()
# ->name($baseFile)
# ->extras({ follow => 1 })
# ->in($documentRoot);
# if (@docrootfiles > 0)
# {
# my $file0 = $docrootfiles[0];
# $phpFile = $file0;
# }
# elsif (@docrootfiles > 1) {}# this is a bug...
# }
# my $newName = $phpFile;
# $newName =~ s/$documentRoot2//g;
# $newName =~ s/^\///g;
# my $abPath = abs_path($phpFile);
# my $dest = "$workingFolder/wwwroot/${newName}_copy";
# my $destdirname = dirname($dest);
# if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: Copying phpFile: From: $abPath | To: $dest\n"); }
# if (! -d $destdirname)
# {
# my $dirs = eval { mkpath($destdirname) };
# die "Failed to create $destdirname: $@\n" unless $dirs;
# }
# File::Copy::copy($abPath, $dest) or die "Failed to copy $abPath: $!\n";;
# $filecopied = TRUE;
# }
# }
# }
@files = File::Find::Rule->file()
->name("*_copy")
->in("$workingFolder/wwwroot");
@ -797,7 +719,6 @@ sub pars_PublishSite
close $out;
if (!$settingsInserted)
{
# print $out $settingsLine;
# delete the file
unlink $outFile;
}
@ -832,7 +753,6 @@ sub pars_PublishSite
$siteType = "joomla";
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: Searching for Joomla site found\n"); }
my $originalConfig = @files[0];
# ilog_print(1, "php read_joomla_settings.php $originalConfig $workingFolder/config-out.txt;");
`php read_joomla_settings.php "$originalConfig" "$workingFolder/config-out.txt";`;
open my $originalConfig, '<', "$workingFolder/config-out.txt" or die "Can't read config-out.txt: $!";
while (my $line = <$originalConfig>)
@ -875,10 +795,7 @@ sub pars_PublishSite
elsif ($strYesOrNo=~/^\s*[Yy]\s*$/)
{
mkdir "$workingFolder/wwwroot";
my @filesToCopy;
# @files = File::Find::Rule->file()
# ->name("*.php")
# ->in($documentRoot);
my @filesToCopy;
for my $phpFile (@files)
{
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: JOOMLA: modifying $phpFile\n"); }
@ -930,7 +847,6 @@ sub pars_PublishSite
@files = File::Find::Rule->file()
->name("*_copy")
->in("$workingFolder/wwwroot");
# my $settingsLine = "\$databases['default']['default']=array('driver'=>'mysql','database' =>'$rDatabase','username'=>'$rUsername','password'=>'$rPassword','host'=>'$rServer','port' => '','prefix' => '');\n";
my $settingsLine = "public \$db = '$rDatabase';\npublic \$user = '$rUsername';\npublic \$password = '$rPassword';\npublic \$host = '$rServer';\n";
for my $phpFile (@files)
{
@ -965,7 +881,6 @@ sub pars_PublishSite
close $out;
if (!$settingsInserted)
{
# print $out $settingsLine;
# delete the file
unlink $outFile;
}
@ -1044,11 +959,7 @@ sub getConfigFiles
my $documentRoot = $_[0];
my $matchLine = $_[1];
my $workingFolder = $_[2];
ilog_print(1,"ARGS: $documentRoot | matchLine: $matchLine | workingFolder: $workingFolder\n");
my @files = @{$_[3]};
#ilog_print(1,"ARGS: $documentRoot | matchLine: $matchLine | workingFolder: $workingFolder\n");
my @files = @{$_[3]};
for my $phpFile (@files)
{
open my $fh, '<', $phpFile or die "Failed to open $_: $!";
@ -1122,7 +1033,7 @@ sub updateTrackingStatus
$escapedName =~ s/!/_x-bang_/g;
use URI;
my $uri = URI->new( "${SITE_URL}/api/${statusType}/${guid}/sitename/${escapedName}/" );
my $baseAddress = $uri;
my $baseAddress = $uri;
# PUT at URL
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new("PUT", $baseAddress);
@ -1135,7 +1046,7 @@ sub updateTrackingStatus
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: Update status result\n: $rContent\n"); }
}
# Returns success
# Returns HTTP response code
sub deployToSite
{
my $publishUrl = shift;
@ -1236,7 +1147,7 @@ sub deployToSite
ilog_print(1,"\n");
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: content upload response code: $rCode\n"); }
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: content upload result: $rContent\n"); }
ilog_print(1,"\n$itemToAdd published with response code: $rCode\n");
ilog_print(1,"\n$itemToAdd published with response code: $rCode\nTo site: $publishUrl");
close $fileZip;
return $rCode;
}

Просмотреть файл

@ -1,8 +1,8 @@
#----------------------------------------------------------------------------------------------
#Script Name : wsmk_userInterface.pm
#Script Name : aamt_userInterface.pm
#Description : Package is used to define methods used for User Interface
use strict;
use wsmk_constants;
use aamt_constants;
#-----------------------------------------------------------------------------------------------
#Method Name : ui_printLine

Просмотреть файл

@ -1,11 +1,11 @@
#----------------------------------------------------------------------------------------------
#Script Name : wsmk_utilityfunctions.pm
#Script Name : aamt_utilityfunctions.pm
#Description : General utility functions.
#use of standard packages
use Cwd;
#use of custom packages
use wsmk_constants;
use aamt_constants;
use LWP::Simple;
use FileHandle;
@ -367,17 +367,17 @@ sub utf_FileOpen
}
#command to open file
open $fhandle, $OpenModeName or die "WSMK_ERR_FILEOPEN_FAILED";
open $fhandle, $OpenModeName or die "AAMT_ERR_FILEOPEN_FAILED";
};
if($@)
{
if ($@ =~ /WSMK_ERR_FILEOPEN_FAILED/ )
if ($@ =~ /AAMT_ERR_FILEOPEN_FAILED/ )
{
$fhandle = WSMK_ERR_FILEOPEN_FAILED;
$fhandle = AAMT_ERR_FILEOPEN_FAILED;
$ret = 0;
$logFileReturn= ilog_displayandLog( WSMK_ERR_FILEOPEN_FAILED,DEBUG_ONLY,'INT_ERROR',WSMK_ERR_FILEOPEN_FAILED,"$FileName", __LINE__);
$logFileReturn= ilog_displayandLog( AAMT_ERR_FILEOPEN_FAILED,DEBUG_ONLY,'INT_ERROR',AAMT_ERR_FILEOPEN_FAILED,"$FileName", __LINE__);
}
}

Просмотреть файл

@ -6,7 +6,7 @@
#Return : returns the current working folder
#-------------------------------------------------------------------------------
use Cwd;
use wsmk_constants;
use aamt_constants;
sub main_getCurrentLibFolder
{
my $libFolder = cwd;

Просмотреть файл

@ -1,7 +1,7 @@
use strict;
# package used to get the current working folder
use wsmk_wrkFolder;
use aamt_wrkFolder;
my $currentLibfolder;
# get the current working folder and unset the environment variable that has been set in the
# batch file/ shell script file
@ -20,13 +20,13 @@ use File::Listing; #to display a list of files in a directory
use Time::localtime; #get system time information
# custom packages developed to be used by the tool
use wsmk_constants; #for user input or error or file constants
use wsmk_utilityFunctions; #for common procedures
use wsmk_informationLog; #used for logging information into Log,Status or Recovery file
use wsmk_userInterface; #used for user interface definition
use wsmk_auth; #used for Authentication and user query module
use wsmk_parse; #used for parsing the conf file and getting the site information
use wsmk_parse2; #used for parsing the conf file and generating the 2D array.
use aamt_constants; #for user input or error or file constants
use aamt_utilityFunctions; #for common procedures
use aamt_informationLog; #used for logging information into Log,Status or Recovery file
use aamt_userInterface; #used for user interface definition
use aamt_auth; #used for Authentication and user query module
use aamt_parse; #used for parsing the conf file and getting the site information
use aamt_parse2; #used for parsing the conf file and generating the 2D array.
# main subroutine starts here
my $localConfFilePath;