Public/Utils.ps1
<#
.SYNOPSIS Attempts to clear the /tmp directory when run from Linux #> function Clear-Tmp() { if ($IsLinux) { try { Remove-Item -Recurse -Path "/tmp/*" } catch { # Ignore } } } function New-TemporaryDirectory { return if ($IsLinux) { "/tmp/$([guid]::NewGuid().ToString())" } else { New-TemporaryFile | % { rm $_; mkdir $_ } } } function Expand-Archive { param ( [string]$zipfile, [string]$outpath ) [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) } function Expand-RemoteArchive { param ( [string]$tempDir, [string]$url, [string]$executableName = $null ) $ProgressPreference = 'SilentlyContinue' $tmpFile = "$tempDir/$([guid]::NewGuid().ToString())" Invoke-WebRequest -Uri $url -OutFile $tmpFile Expand-Archive $tmpFile $tmpDir if ($executableName -ne $null) { if ($IsLinux) { chmod 500 "$tmpDir/$executableName" } } } function Enable-TLS12 { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } |