Skip to content

Commit dab13f2

Browse files
committed
Update genall.ps1
1 parent 768d214 commit dab13f2

File tree

1 file changed

+107
-2
lines changed

1 file changed

+107
-2
lines changed

generate/genall.ps1

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $script:FailedModules = 0
3434

3535
# Variables for tracking execution stages
3636
$script:CurrentMainStep = 0
37-
$script:TotalMainSteps = 8
37+
$script:TotalMainSteps = 9
3838
$script:CurrentAddonSubStep = 0
3939
$script:TotalAddonSubSteps = 6
4040
$script:CurrentToolSubStep = 0
@@ -791,6 +791,102 @@ function Install-LocalFiles {
791791
}
792792
}
793793

794+
function Install-PhpMyAdmin {
795+
param(
796+
[string]$DownloadUrl = "https://files.phpmyadmin.net/phpMyAdmin/5.2.2/phpMyAdmin-5.2.2-all-languages.zip",
797+
[string]$TargetDir = "..\home\phpmyadmin"
798+
)
799+
800+
try {
801+
Write-Stage "PHPMYADMIN" "Preparing target directory" $TargetDir
802+
if (-not (Test-Path $TargetDir)) {
803+
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
804+
Write-Success "Created directory: $TargetDir"
805+
} else {
806+
Write-Success "Target directory exists: $TargetDir"
807+
}
808+
809+
# Загружаем архив в кэш и во временный файл
810+
$tmpZip = Join-Path $env:TEMP ("pma_" + (Get-Random) + ".zip")
811+
Write-Stage "PHPMYADMIN" "Downloading archive" $DownloadUrl
812+
if (-not (Get-CachedFile -Url $DownloadUrl -OutFile $tmpZip)) {
813+
Write-Error "Failed to download phpMyAdmin archive"
814+
return $false
815+
}
816+
817+
# Распаковываем во временную папку
818+
$tmpExtract = New-TempDir
819+
Write-Stage "PHPMYADMIN" "Extracting to temp" $tmpExtract
820+
try {
821+
Expand-Archive -Path $tmpZip -DestinationPath $tmpExtract -Force
822+
} catch {
823+
Write-Error "Error extracting phpMyAdmin archive: $_"
824+
Remove-Item $tmpZip -Force -ErrorAction SilentlyContinue
825+
Remove-Item $tmpExtract -Recurse -Force -ErrorAction SilentlyContinue
826+
return $false
827+
}
828+
829+
# Находим корневую папку внутри архива (обычно "phpMyAdmin-5.2.2-all-languages")
830+
$innerDir = Get-ChildItem -Path $tmpExtract -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
831+
if (-not $innerDir) {
832+
$innerDirPath = $tmpExtract
833+
} else {
834+
$innerDirPath = $innerDir.FullName
835+
}
836+
837+
# Копируем содержимое в ..\home\phpmyadmin БЕЗ ПЕРЕЗАПИСИ СУЩЕСТВУЮЩИХ ФАЙЛОВ
838+
# ВАЖНО: именно без замены (если файл существует — пропускаем его).
839+
Write-Stage "PHPMYADMIN" "Copying files without overwrite" $TargetDir
840+
841+
$copied = 0
842+
$skipped = 0
843+
844+
# Копируем каталоги
845+
Get-ChildItem -Path $innerDirPath -Recurse -Force | ForEach-Object {
846+
$relPath = $_.FullName.Substring($innerDirPath.Length).TrimStart('\','/')
847+
$destPath = Join-Path $TargetDir $relPath
848+
849+
if ($_.PSIsContainer) {
850+
if (-not (Test-Path $destPath)) {
851+
New-Item -ItemType Directory -Force -Path $destPath | Out-Null
852+
}
853+
return
854+
}
855+
856+
# Файл: если уже существует — пропускаем, иначе копируем
857+
if (Test-Path $destPath -PathType Leaf) {
858+
$skipped++
859+
} else {
860+
Ensure-Directory -FilePath $destPath
861+
try {
862+
Copy-Item -Path $_.FullName -Destination $destPath -Force:$false
863+
$copied++
864+
} catch {
865+
# На случай, если PowerShell всё же пытается перезаписать — перестрахуемся
866+
if (-not (Test-Path $destPath)) {
867+
Copy-Item -Path $_.FullName -Destination $destPath
868+
$copied++
869+
} else {
870+
$skipped++
871+
}
872+
}
873+
}
874+
}
875+
876+
Write-Success "phpMyAdmin copied: $copied new files, skipped (already exist): $skipped"
877+
878+
# Удаляем временные файлы
879+
Remove-Item $tmpZip -Force -ErrorAction SilentlyContinue
880+
Remove-Item $tmpExtract -Recurse -Force -ErrorAction SilentlyContinue
881+
882+
Write-Success "phpMyAdmin installation completed"
883+
return $true
884+
} catch {
885+
Write-Error "phpMyAdmin installation error: $_"
886+
return $false
887+
}
888+
}
889+
794890
function Generate-ToolHelp {
795891
param([array]$Command, [string]$OutputFile = $null)
796892
if (-not $OutputFile) { $OutputFile = "$($Command[0] -replace '\.exe$', '').txt" }
@@ -1832,9 +1928,18 @@ Write-Host ""
18321928
Write-Banner "STEP $($script:CurrentMainStep)/$($script:TotalMainSteps): COPYING ADDITIONAL FILES" "Magenta"
18331929
Copy-AdditionalFiles
18341930

1835-
# STEP 8: Final Statistics
18361931
$script:CurrentMainStep = 8
18371932
Write-Host ""
1933+
Write-Banner "STEP $($script:CurrentMainStep)/$($script:TotalMainSteps): INSTALLING PHPMYADMIN" "Magenta"
1934+
if (-not (Install-PhpMyAdmin)) {
1935+
Write-Warning "Critical error installing phpMyAdmin"
1936+
} else {
1937+
Write-Success "phpMyAdmin successfully installed"
1938+
}
1939+
1940+
# STEP 8: Final Statistics
1941+
$script:CurrentMainStep = 9
1942+
Write-Host ""
18381943
Write-Banner "STEP $($script:CurrentMainStep)/$($script:TotalMainSteps): FINAL STATISTICS" "Green"
18391944
Show-Summary
18401945

0 commit comments

Comments
 (0)