-
Notifications
You must be signed in to change notification settings - Fork 27
/
run.ps1
51 lines (43 loc) · 1.25 KB
/
run.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
param
(
[Alias("m")]
[switch]$mirror
)
function Run-SpotX {
param(
[string]$params
)
$maxRetryCount = 3
$retryInterval = 5
if ($mirror) {
$url = 'https://spotx-official.github.io/SpotX/run.ps1'
$params += " -m"
}
else {
$url = 'https://raw.githubusercontent.com/SpotX-Official/SpotX/main/run.ps1'
}
for ($retry = 1; $retry -le $maxRetryCount; $retry++) {
try {
$response = iwr -useb $url
$StatusCode = $response.StatusCode
}
catch {
$StatusCode = $_.Exception.Response.StatusCode.value__
}
if ($StatusCode -eq 200) {
iex "& {$($response)} $params"
return
}
else {
Write-Host ("Attempt $($retry): HTTP status code: $($StatusCode). Retrying in $($retryInterval) seconds...")
Start-Sleep -Seconds $retryInterval
}
}
Write-Host
Write-Warning "Failed to make the request after $maxRetryCount attempts, script terminated."
Write-Host $Error[0].Exception.Message
pause
exit
}
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;
Run-SpotX -params $args