install-podman.ps1 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <#
  2. .Description
  3. The script installs and sets up podman.
  4. .PARAMETER BASE_DIR
  5. Determines where the binaries will be downloaded. This defaults to user's temp directory.
  6. #>
  7. param (
  8. [Parameter(
  9. Position = 0
  10. )]
  11. [string]$BASE_DIR = $Env:TEMP ##
  12. )
  13. $BASE_DIR = $BASE_DIR + "\"
  14. $PODMAN_VERSION = '4.7.2'
  15. $PODMAN_SHA256 = "2124ac24e2c730f16e07e8eb033d5675d0f6123669c27d525d43d2f51f96b1ba"
  16. $PODMAN_URL = "https://github.com/containers/podman/releases/download/v$PODMAN_VERSION/podman-$PODMAN_VERSION-setup.exe"
  17. $PODMAN_SETUP = $BASE_DIR + 'podman-setup.exe'
  18. $PODMAN_INSTALL_PATH = "C:\Program Files\RedHat\Podman\"
  19. # Download podman
  20. Invoke-WebRequest $PODMAN_URL -Out $PODMAN_SETUP
  21. Write-Host "Verifying podman integrity"
  22. if ((Get-FileHash $PODMAN_SETUP -Algorithm SHA256).Hash -ne $PODMAN_SHA256) {
  23. Write-Host "$PODMAN_SETUP sha did not match"
  24. Break
  25. }
  26. # Install podman
  27. Write-Host "Installing podman. You may skip rebooting for machine for now"
  28. Start-Process $PODMAN_SETUP /norestart -NoNewWindow -Wait
  29. # Update PATH to contain podman directory.
  30. $Env:PATH = $Env:PATH + ";" + $PODMAN_INSTALL_PATH
  31. # create and start a wsl2 machine for podman to use
  32. podman machine init
  33. podman machine start
  34. Write-Host "podman installed successfully. You may need to add $PODMAN_INSTALL_PATH to your PATH"