-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchromium_github.ps1
97 lines (84 loc) · 3.16 KB
/
chromium_github.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# GitHub API endpoint
$apiUrl = "https://api.github.com/repos/Hibbiki/chromium-win64/releases/latest"
$installDir = "$env:LOCALAPPDATA\Chromium"
$currentVersionFile = "$installDir\version.txt"
$chromiumExePath = "${env:ProgramFiles}\Chromium\Application\chrome.exe"
function Get-CurrentVersion {
if (Test-Path $currentVersionFile) {
return Get-Content $currentVersionFile
}
# Dosya yoksa kurulu Chromium'dan versiyon kontrolü yap
elseif (Test-Path $chromiumExePath) {
$version = (Get-Item $chromiumExePath).VersionInfo.FileVersion
return $version
}
return $null
}
function Install-Chromium {
param (
[string]$downloadUrl,
[string]$version
)
try {
if ([string]::IsNullOrEmpty($downloadUrl)) {
throw "İndirme URL'si bulunamadı!"
}
Write-Host "Chromium indiriliyor..."
$tempFile = "$env:TEMP\chromium_installer.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempFile -UseBasicParsing
if (-not (Test-Path $tempFile)) {
throw "İndirme başarısız oldu!"
}
Write-Host "Chromium kuruluyor..."
$process = Start-Process -FilePath $tempFile -ArgumentList "/silent" -Wait -PassThru
if ($process.ExitCode -ne 0) {
throw "Kurulum başarısız oldu! Exit code: $($process.ExitCode)"
}
# Versiyon bilgisini kaydet
if (-not (Test-Path $installDir)) {
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
}
$version | Out-File $currentVersionFile -Force
Write-Host "Kurulum tamamlandı."
Remove-Item $tempFile -Force
return $true
}
catch {
Write-Host "Hata oluştu: $_" -ForegroundColor Red
if (Test-Path $tempFile) {
Remove-Item $tempFile -Force
}
return $false
}
}
try {
$headers = @{
"Accept" = "application/vnd.github.v3+json"
"User-Agent" = "PowerShell Script"
}
Write-Host "Güncellemeler kontrol ediliyor..."
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers
$latestVersion = $response.tag_name
$currentVersion = Get-CurrentVersion
# İndirme URL'sini bul (sync installer'ı tercih et)
$downloadUrl = ($response.assets | Where-Object { $_.name -like "*mini_installer.sync.exe" }).browser_download_url
if (-not $currentVersion) {
Write-Host "Chromium kurulu değil. Kuruluyor..."
if (Install-Chromium -downloadUrl $downloadUrl -version $latestVersion) {
Write-Host "Kurulum başarılı!" -ForegroundColor Green
}
}
elseif ($currentVersion -ne $latestVersion) {
Write-Host "Yeni sürüm bulundu: $latestVersion" -ForegroundColor Yellow
Write-Host "Mevcut sürüm: $currentVersion"
if (Install-Chromium -downloadUrl $downloadUrl -version $latestVersion) {
Write-Host "Güncelleme başarılı!" -ForegroundColor Green
}
}
else {
Write-Host "Chromium güncel: $currentVersion" -ForegroundColor Green
}
}
catch {
Write-Host "Hata oluştu: $_" -ForegroundColor Red
}