Skip to content

Commit 2c973db

Browse files
committed
feat(curl): add retries and timeouts
1 parent 9a3209f commit 2c973db

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/playbook/Executables/LIBREWOLF.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.\AtlasModules\initPowerShell.ps1
22
$ProgressPreference = "SilentlyContinue"
33
$ErrorActionPreference = "Stop"
4+
$timeouts = @("--connect-timeout", "5", "--max-time", "10", "--retry", "5", "--retry-delay", "0", "--retry-max-time", "40", "--retry-all-errors")
45

56
# Initial variables
67
$drive = Get-SystemDrive
@@ -21,7 +22,7 @@ $librewolfDownload = "https://gitlab.com/api/v4/projects/$gitLabId/packages/gene
2122

2223
Write-Output "Downloading the latest LibreWolf setup"
2324
$outputLibrewolf = "$drive\$librewolfFileName"
24-
curl.exe -LSs "$librewolfDownload" -o "$outputLibrewolf"
25+
curl.exe -LSs "$librewolfDownload" -o "$outputLibrewolf" $timeouts
2526

2627
Write-Output "Installing LibreWolf silently"
2728
Start-Process -Wait -FilePath $outputLibrewolf -ArgumentList "/S"
@@ -42,7 +43,7 @@ $librewolfUpdaterDownload = (Invoke-RestMethod -Uri "$librewolfUpdaterURI").Asse
4243

4344
Write-Output "Downloading the latest LibreWolf WinUpdater ZIP"
4445
$outputLibrewolfUpdater = "$drive\librewolf-winupdater.zip"
45-
curl.exe -LSs "$librewolfUpdaterDownload" -o "$outputLibrewolfUpdater"
46+
curl.exe -LSs "$librewolfUpdaterDownload" -o "$outputLibrewolfUpdater" $timeouts
4647

4748
Write-Output "Extracting Librewolf-WinUpdater"
4849
Expand-Archive -Path $outputLibrewolfUpdater -DestinationPath "$programs\LibreWolf\librewolf-winupdater" -Force

src/playbook/Executables/SOFTWARE.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ param (
1010
# Software is no longer installed with a package manager anymore to be as fast and as reliable as possible. #
1111
# ----------------------------------------------------------------------------------------------------------- #
1212

13+
$timeouts = @("--connect-timeout", "5", "--max-time", "10", "--retry", "5", "--retry-delay", "0", "--retry-max-time", "40", "--retry-all-errors")
1314
$msiArgs = "/qn /quiet /norestart ALLUSERS=1 REBOOT=ReallySuppress"
1415
$arm = ((Get-CimInstance -Class Win32_ComputerSystem).SystemType -match 'ARM64') -or ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64')
1516

@@ -22,7 +23,7 @@ Push-Location $tempDir
2223
# Brave
2324
if ($Brave) {
2425
Write-Output "Downloading Brave..."
25-
& curl.exe -LSs "https://laptop-updates.brave.com/latest/winx64" -o "$tempDir\BraveSetup.exe"
26+
& curl.exe -LSs "https://laptop-updates.brave.com/latest/winx64" -o "$tempDir\BraveSetup.exe" $timeouts
2627
if (!$?) {
2728
Write-Error "Downloading Brave failed."
2829
exit 1
@@ -50,10 +51,10 @@ if ($Firefox) {
5051
$firefoxArch = ('win64', 'win64-aarch64')[$arm]
5152

5253
Write-Output "Downloading Firefox..."
53-
& curl.exe -LSs "https://download.mozilla.org/?product=firefox-latest-ssl&os=$firefoxArch&lang=en-US" -o "$tempDir\firefox.exe"
54+
& curl.exe -LSs "https://download.mozilla.org/?product=firefox-latest-ssl&os=$firefoxArch&lang=en-US" -o "$tempDir\firefox.exe" $timeouts
5455
Write-Output "Installing Firefox..."
5556
Start-Process -FilePath "$tempDir\firefox.exe" -WindowStyle Hidden -ArgumentList '/S /ALLUSERS=1' -Wait
56-
57+
5758
Remove-TempDirectory
5859
exit
5960
}
@@ -62,7 +63,7 @@ if ($Firefox) {
6263
if ($Chrome) {
6364
Write-Output "Downloading Google Chrome..."
6465
$chromeArch = ('64', '_Arm64')[$arm]
65-
& curl.exe -LSs "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise$chromeArch.msi" -o "$tempDir\chrome.msi"
66+
& curl.exe -LSs "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise$chromeArch.msi" -o "$tempDir\chrome.msi" $timeouts
6667
Write-Output "Installing Google Chrome..."
6768
Start-Process -FilePath "$tempDir\chrome.msi" -WindowStyle Hidden -ArgumentList '/qn' -Wait
6869

@@ -107,7 +108,7 @@ foreach ($a in $vcredists.GetEnumerator()) {
107108

108109
# curl is faster than Invoke-WebRequest
109110
Write-Output "Downloading and installing Visual C++ Runtime $vcName..."
110-
& curl.exe -LSs "$vcUrl" -o "$vcExePath"
111+
& curl.exe -LSs "$vcUrl" -o "$vcExePath" $timeouts
111112

112113
if ($vcArgs -match ":") {
113114
$msiDir = "$tempDir\vcredist-$vcName"
@@ -132,7 +133,7 @@ function Install7Zip {
132133
$7zipArch = ('x64', 'arm64')[$arm]
133134
$download = $website + ((Invoke-WebRequest $website -UseBasicParsing).Links.href | Where-Object { $_ -like "a/7z*-$7zipArch.exe" })
134135
Write-Output "Downloading 7-Zip..."
135-
& curl.exe -LSs $download -o "$tempDir\7zip.exe"
136+
& curl.exe -LSs $download -o "$tempDir\7zip.exe" $timeouts
136137
Write-Output "Installing 7-Zip..."
137138
Start-Process -FilePath "$tempDir\7zip.exe" -WindowStyle Hidden -ArgumentList '/S' -Wait
138139
}
@@ -145,7 +146,7 @@ function InstallNanaZip {
145146
$assets | ForEach-Object {
146147
$filename = $_ -split '/' | Select-Object -Last 1
147148
Write-Output "Downloading '$filename'..."
148-
& curl.exe -LSs $_ -o "$path\$filename"
149+
& curl.exe -LSs $_ -o "$path\$filename" $timeouts
149150
}
150151

151152
Write-Output "Installing NanaZip..."
@@ -187,7 +188,7 @@ NanaZip is a fork of 7-Zip with an updated user interface and extra features.
187188
}
188189

189190
# Legacy DirectX runtimes
190-
& curl.exe -LSs "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe" -o "$tempDir\directx.exe"
191+
& curl.exe -LSs "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe" -o "$tempDir\directx.exe" $timeouts
191192
Write-Output "Extracting legacy DirectX runtimes..."
192193
Start-Process -FilePath "$tempDir\directx.exe" -WindowStyle Hidden -ArgumentList "/q /c /t:`"$tempDir\directx`"" -Wait
193194
Write-Output "Installing legacy DirectX runtimes..."

0 commit comments

Comments
 (0)