Signed-off-by: Ubuntu <faiz@faiz1234.qxtipznhomuelnqzqjon0ldwid.xx.internal.cloudapp.net>
This commit is contained in:
Ubuntu 2018-12-15 12:01:10 +00:00
Родитель 384184708d
Коммит a84f8363ae
6 изменённых файлов: 137 добавлений и 21 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -23,4 +23,5 @@ nytprof.out
*.tar.gz
*.tar
*-junk*
Azure-Apache-Migration-Tool/
Azure-Apache-Migration-Tool/
/.sessions/

15
.htaccess Normal file
Просмотреть файл

@ -0,0 +1,15 @@
# Turn off all options we don't need.
Options None
Options +FollowSymLinks
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>

30
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"exec": "perl",
"execArgs": ["migrate_tool_main.pl"],
"root": "${workspaceRoot}/",
"inc": [],
"args": [],
"env": {},
"stopOnEntry": true
},
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
"root": "${workspaceRoot}/",
"stopOnEntry": true,
"port": 5000
}
]
}

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

@ -71,7 +71,7 @@ my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
#get session name
my $strSessionName = &ilog_getSessionName();
#form the complete working folder
my $workingFolder = $strCurWorkingFolder . '/' . $strSessionName;
my $workingFolder = $strCurWorkingFolder . '/.sessions/' . $strSessionName;
#----------------------------------------------------------------------------------------------------------------------
$siteIndex[0] = 'SITENAME';
@ -323,8 +323,8 @@ sub pars_CreateReadinessReport
}
}
ilog_print(1,"\nReadiness report uploaded, to continue navigate to:\n ${SITE_URL}/results/index/$guid\n\nCreate site and databases and then download and save the publish settings file to this computer.");
ilog_print(1,"\nReadiness report uploaded, to view it navigate to:\n ${SITE_URL}/results/index/$guid\n\nCreate site and databases and then download and save the publish settings file to this computer.");
ilog_print(1,"\n Please create the resources using https://aka.ms/webappmysql and then download publishing profile from the web app blade in portal to proceed \n");
# write the readiness report to a file
my $outFile = "$workingFolder/readinessreport.json";
open my $out, '>', $outFile or die "Can't write to $outFile file: $!";
@ -452,14 +452,23 @@ sub pars_PublishSite
my $userName;
my $userPWD;
my $mySqlConnectionString;
my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
my $strSessionName = &ilog_getSessionName();
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
while (!$publishSuccess)
{
if ($DEBUG_MODE) { ilog_print(1,"\nDEBUG: strPublishSettings: $strPublishSettings \n"); }
my $xml = XML::Simple->new;
my $data = $xml->XMLin($strPublishSettings, ForceArray => ['publishProfile']);
for my $entry (@{$data->{publishProfile}})
{
my $key = $entry->{originalsitename};
if ($key eq $rComputername.":".$strSiteName)
my $key = $entry->{publishMethod};
if ( index($key,"MSDeploy")!=-1 )# $rComputername.":".$strSiteName)
{
$publishUrl = $entry->{publishUrl};
$userName = $entry->{userName};
@ -470,10 +479,10 @@ sub pars_PublishSite
{
$mySqlConnectionString = $dbs->{add}->{connectionString};
}
last;
}
}
ilog_print(1,"Calling deployToSite with : $publishUrl, $documentRoot, $userName, $userPWD");
my $rCode = &deployToSite($publishUrl, $documentRoot, $userName, $userPWD, TRUE);
if ($rCode !~ /^\s*2[0-9]*/)
@ -559,8 +568,8 @@ sub pars_PublishSite
}
elsif ($framework eq DRUPAL)
{
# TODO: improve drupal detection logic
$lineMatch = qr/databases.*'default'.*'default'/;
# TODO: improve drupal detection logic qr/databases.*'default'.*'default'\s*\$databases
$lineMatch = qr/databases.*'default'.*'default'|\$databases/;
$settingsLine = "\$databases['default']['default']=array('driver'=>'mysql','database' =>'$rDatabase','username'=>'$rUsername','password'=>'$rPassword','host'=>'$rServer','port' => '','prefix' => '');\n";
}
elsif ($framework eq JOOMLA)
@ -597,12 +606,31 @@ sub pars_PublishSite
$outFile =~ s/_copy//g;
open my $out, '>', $outFile or die "Can't write to $outFile file: $!";
my $openBracket = FALSE;
my $commentLine = FALSE;
while (my $line = <$fh>)
{
if ($line =~ $lineMatch && ($lineNotMatch eq "" || $line !~ $lineNotMatch))
my $trim = trim($line) ;
#$trim =~ s/^\s+|\s+$//g;
if(begins_with($trim, "*")|| begins_with($trim, "/*") || begins_with($trim, "//") || ends_with($trim, "*/"))
#if ($line =~ /\*(?:.|[\r\n])*?\*/ )
{
$commentLine = TRUE;
}
else
{
$commentLine = FALSE;
}
#if ($DEBUG_MODE)
#{ ilog_print(1,"\ncommentline:$commentLine \n$line$trim"); }
if (!$commentLine)
{
if ($line =~ $lineMatch && ($lineNotMatch eq "" || $line !~ $lineNotMatch))
{
if (!$settingsInserted)
{
print $out "// SETTING INSERTED BY AZURE APP SERVICE MIGRATION TOOL:\n";
print $out $settingsLine;
$settingsInserted = TRUE;
print $out "// COMMENTED OUT BY AZURE APP SERVICE MIGRATION TOOL: $line";
@ -619,7 +647,11 @@ sub pars_PublishSite
{
print $out $line;
}
}
else
{
print $out $line;
}
if ($openBracket && $line =~ ';')
{
$openBracket = FALSE;
@ -698,14 +730,39 @@ sub pars_PublishSite
}
}
}
sub trim
{
my $s =shift; $s =~ s/^\s+|\s+$//g;
return $s;
}
sub begins_with
{
return (index($_[0],$_[1]) == 0) ;
#return substr($_[0], length($_[1])) eq $_[1];
}
sub ends_with
{
# return (index($_[0],$_[1]) ==1) ;
if (length($_[0])<length($_[1]))
{
return FALSE;
}
else
{
return substr($_[0], length($_[0])-length($_[1])) eq $_[1];
}
}
sub getConfigFiles
{
my $documentRoot = $_[0];
my $lineMatch = $_[1];
my $lineNotMatch = $_[2];
# my $workingFolder = $_[3];
my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
my $strSessionName = &ilog_getSessionName();
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
my @files = @{$_[3]};
for my $phpFile (@files)
@ -836,9 +893,9 @@ sub deployToSite
$zip->addFile($itemToAdd, $filename);
}
# my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
# my $strSessionName = &ilog_getSessionName();
# my $workingFolder = $strCurWorkingFolder . '/' . $strSessionName;
my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
my $strSessionName = &ilog_getSessionName();
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
my $zipLocation = "$workingFolder/site-content.zip";
if ( $zip->writeToFileNamed($zipLocation) != AZ_OK )
{
@ -2119,6 +2176,10 @@ sub pars_siteHasValidFrameworkDb
my $dbUser;
my $dbPassword;
my $dbHost;
my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
my $strSessionName = &ilog_getSessionName();
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
if ($framework eq WORDPRESS)
{
`php read_wp_settings.php "$configFile" "$workingFolder/${framework}-settings.txt";`;
@ -6618,7 +6679,7 @@ sub pars_createXML
if($array[$i][SITENAME] eq $arrayDir[$j][SITENAME])
{
@temp = split /\²/,$array[$i][ALIAS];
@temp = split /\<EFBFBD>/,$array[$i][ALIAS];
for($k=0;$k<$#temp; $k = $k + 2)
{
@ -6875,7 +6936,7 @@ sub pars_createXML
my $k = 0;
if($array[$i][SITENAME] eq $arrayDir[$j][SITENAME])
{
@temp = split /\²/,$array[$i][SCRIPTALIAS];
@temp = split /\<EFBFBD>/,$array[$i][SCRIPTALIAS];
for($k=0;$k<$#temp; $k = $k + 2)
{
my $directoryName;

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

@ -280,7 +280,7 @@ sub utf_getWorkingFolder
#get session name
my $strSessionName = &ilog_getSessionName();
#form the complete working folder
my $workingFolder = $strCurWorkingFolder . '/' . $strSessionName;
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
return $workingFolder;
}

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

@ -69,7 +69,7 @@ eval
# get session name
my $strSessionName = &ilog_getSessionName();
# form the complete working folder
my $workingFolder = $strCurWorkingFolder . '/' . $strSessionName;
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
# change local dir
my $retwrk_changeLocalDir = wrk_changeLocalDir($workingFolder);
if (!($retwrk_changeLocalDir))
@ -151,15 +151,24 @@ sub TerminateTool
sub DeleteWorkingFolder
{
my $strYesOrNo = "";
# get the current working folder
my $strCurWorkingFolder = &utf_getCurrentWorkingFolder();
#get session name
my $strSessionName = &ilog_getSessionName();
#form the complete working folder
my $workingFolder = $strCurWorkingFolder . '/sessions/' . $strSessionName;
while($strYesOrNo!~/^\s*[YynN]\s*$/)
{
ilog_printf(1, " Would you like to delete the working folder used to store temporary settings? (Y/N):");
ilog_printf(1, " Would you like to delete the working folder $workingFolder used to store temporary settings? (Y/N):");
chomp($strYesOrNo = <STDIN>);
ilog_print(0,ERR_INVALID_INPUT.ERR_ONLY_YES_OR_NO)
if ($strYesOrNo!~/^\s*[YynN]\s*$/);
if ($strYesOrNo=~/^\s*[Yy]\s*$/)
{
rmtree([&utf_getCurrentWorkingFolder()]);
rmtree([$workingFolder]);
}
}
}