From fe9d11c4066945a0d28fd48a6a69c786de83713d Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 14:14:18 +0200 Subject: [PATCH 01/12] Update install.ps1 --- install.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/install.ps1 b/install.ps1 index 7dc4a53..cf9f4ed 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,5 +1,3 @@ -#Requires -RunAsAdministrator - #region variables param( @@ -10,6 +8,13 @@ param( [switch]$RenameBinaries = $false ) +$script:parameters = "" + +foreach ($boundParam in $PSBoundParameters.GetEnumerator()) +{ + $script:parameters += '-{0} ' -f $boundParam.Key +} + $script:rancherDesktopExe = "C:\Users\$env:UserName\AppData\Local\Programs\Rancher Desktop\Rancher Desktop.exe" $script:windowsBinariesPath = "C:\Users\$env:UserName\AppData\Local\Programs\Rancher Desktop\resources\resources\win32\bin" $script:linuxBinariesPath = "C:\Users\$env:UserName\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin" @@ -294,9 +299,12 @@ if($Alias -and $RenameBinaries) if($Help) { Help - exit 1 + exit 0 } +# Elevate script if needed. +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $($script:parameters)" -Verb RunAs; exit } + IsDockerDesktopInstalled if($WindowsContainers) From cbc3c431b5e1d505b9f93d44d7f21680a97389d9 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 14:15:10 +0200 Subject: [PATCH 02/12] Update start.ps1 --- start.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start.ps1 b/start.ps1 index 00f027b..643903f 100644 --- a/start.ps1 +++ b/start.ps1 @@ -1,5 +1,5 @@ -if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $($args)" -Verb RunAs; exit } Start-Service docker -Add-AccountToDockerAccess "$env:UserDomain\$env:UserDomain" \ No newline at end of file +Add-AccountToDockerAccess "$env:UserDomain\$env:UserDomain" From 68a1b989f66375786f600a5bfa3380813b22f56f Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 14:16:29 +0200 Subject: [PATCH 03/12] Update uninstall.ps1 --- uninstall.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.ps1 b/uninstall.ps1 index 9d06c0d..2b14e4f 100644 --- a/uninstall.ps1 +++ b/uninstall.ps1 @@ -1,4 +1,4 @@ -#Requires -RunAsAdministrator +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $($args)" -Verb RunAs; exit } #region variables From bd45cc9fe3ea39bef1970941764e7405dda2daf7 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 15:53:09 +0200 Subject: [PATCH 04/12] Update README.asciidoc --- README.asciidoc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index f1fbcd1..fb35f6e 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -8,22 +8,24 @@ If you are new to containers or you are not already familiar with Docker, we enc The script `install.ps1` will install the Rancher Desktop solution along with some extra features: +* Support for usual Docker commands in Powershell and Bash (flag `-Alias`). * Support for enterprise VPNs (flag `-VPN`). * Support (additional) for Windows Containers using Docker binary (flag `-WindowsContainers`). You do not need to choose anymore! -* Support for usual Docker commands in Powershell and Bash (flag `-Alias`). -To install it, clone the repository and run `install.ps1` with the desired flags as administrator. +To install it, clone the repository and run `install.ps1` with the desired flags. -*Tipically, you just need to*: +*Tipically, you just need to either*: ``` -.\install.ps1 -VPN -WindowsContainers -Alias +.\install.ps1 -Alias -VPN -WindowsContainers ``` -IMPORTANT: *Do not enable auto-update in Rancher Desktop settings. VPN support is known to break after v1.1.1.* +*or right-click on the install script and select "Run with PowerShell"*, as it assumes the above flags if ran that way. IMPORTANT: You may be asked to reboot your computer. This happens when you do not have the required Windows features already enabled. If so, relaunch installation process after restart. +CAUTION: Do not enable auto-update in Rancher Desktop settings. VPN support is known to break after v1.1.1. + == Usage Using Linux containers is very simple, just make sure Rancher Desktop is started, that you don't change default containerd runtime, and go ahead running the Docker commands you are used to: From 0584910b96fee218c7b3774656db3f0d7a43c7fb Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 15:56:40 +0200 Subject: [PATCH 05/12] Update install.ps1 --- install.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index cf9f4ed..b00d355 100644 --- a/install.ps1 +++ b/install.ps1 @@ -2,12 +2,20 @@ param( [switch]$Help = $false, + [switch]$Alias = $false, [switch]$VPN = $false, [switch]$WindowsContainers = $false, - [switch]$Alias = $false, [switch]$RenameBinaries = $false ) +if($MyInvocation.InvocationName -eq "&" -and $PSBoundParameters.count -eq 0) +{ + + $PSBoundParameters."Alias" = $true + $PSBoundParameters."VPN" = $true + $PSBoundParameters."WindowsContainers" = $true +} + $script:parameters = "" foreach ($boundParam in $PSBoundParameters.GetEnumerator()) @@ -38,9 +46,9 @@ function Help Write-Host " .\install.ps1 [flags]" Write-Host "" Write-Host "Flags:" + Write-Host " -Alias Creates alias for usual Docker commands in Powershell and Bash." Write-Host " -VPN Enables support for enterprise VPNs." Write-Host " -WindowsContainers Enables support for Windows Containers using Docker binary." - Write-Host " -Alias Creates alias for usual Docker commands in Powershell and Bash." Write-Host "" Write-Host "Advanced Flags:" Write-Host " -RenameBinaries Renames binaries to provide universal docker command support in cases where shell profiles are of no use, but comes with some caveats (e.g. requires using docker compose instead of docker-compose). Incompatible with -Alias flag." From 6cf692a71e8ddb7fa18224e0531489bc141a8190 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 16:05:47 +0200 Subject: [PATCH 06/12] Update README.asciidoc --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index fb35f6e..4dab97a 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -20,7 +20,7 @@ To install it, clone the repository and run `install.ps1` with the desired flags .\install.ps1 -Alias -VPN -WindowsContainers ``` -*or right-click on the install script and select "Run with PowerShell"*, as it assumes the above flags if ran that way. +*or right-click on the install script and select "Run with PowerShell"*, as it defaults to the above flags if run that way. IMPORTANT: You may be asked to reboot your computer. This happens when you do not have the required Windows features already enabled. If so, relaunch installation process after restart. From 5ab4489d68a0145fb26e788323ff25330133b31b Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 16:07:13 +0200 Subject: [PATCH 07/12] Update install.ps1 --- install.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index b00d355..d3e3fe4 100644 --- a/install.ps1 +++ b/install.ps1 @@ -10,7 +10,6 @@ param( if($MyInvocation.InvocationName -eq "&" -and $PSBoundParameters.count -eq 0) { - $PSBoundParameters."Alias" = $true $PSBoundParameters."VPN" = $true $PSBoundParameters."WindowsContainers" = $true From bff892432c14b835f2c2cb4b6e3b171448a93f57 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 16:08:48 +0200 Subject: [PATCH 08/12] Update README.asciidoc --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 4dab97a..f73b140 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -76,6 +76,6 @@ This feature comes disabled by default, but you can activate it on Rancher Deskt == Uninstall -To uninstall Rancher Desktop and all the extra features execute the script `uninstall.ps1` as administrator. +To uninstall Rancher Desktop and all the extra features execute the script `uninstall.ps1`. The uninstall script will cleanup the environment variables, folders and tools, leaving your computer as clean as it was. From 2ad99a2985559fc21ebf1959db9370ecb404e15c Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 16:27:52 +0200 Subject: [PATCH 09/12] Update install.ps1 --- install.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/install.ps1 b/install.ps1 index d3e3fe4..d54d042 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,6 +8,7 @@ param( [switch]$RenameBinaries = $false ) +# When run from context menu (also other situations, but not relevant) if($MyInvocation.InvocationName -eq "&" -and $PSBoundParameters.count -eq 0) { $PSBoundParameters."Alias" = $true From 5c98158609a0b14b8c749d0c0c10b7dbd8c942eb Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 17:13:16 +0200 Subject: [PATCH 10/12] Update install.ps1 --- install.ps1 | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/install.ps1 b/install.ps1 index d54d042..b8b21fa 100644 --- a/install.ps1 +++ b/install.ps1 @@ -11,16 +11,16 @@ param( # When run from context menu (also other situations, but not relevant) if($MyInvocation.InvocationName -eq "&" -and $PSBoundParameters.count -eq 0) { - $PSBoundParameters."Alias" = $true - $PSBoundParameters."VPN" = $true - $PSBoundParameters."WindowsContainers" = $true + $PSBoundParameters."Alias" = $true + $PSBoundParameters."VPN" = $true + $PSBoundParameters."WindowsContainers" = $true } $script:parameters = "" foreach ($boundParam in $PSBoundParameters.GetEnumerator()) { - $script:parameters += '-{0} ' -f $boundParam.Key + $script:parameters += '-{0} ' -f $boundParam.Key } $script:rancherDesktopExe = "C:\Users\$env:UserName\AppData\Local\Programs\Rancher Desktop\Rancher Desktop.exe" @@ -29,7 +29,10 @@ $script:linuxBinariesPath = "C:\Users\$env:UserName\AppData\Local\Programs\Ranch $script:profilePath = "C:\Users\$env:UserName\Documents\WindowsPowerShell\old-profile.ps1" $script:panicFilePath = "C:\ProgramData\docker\panic.log" $script:dockerPackageUrl = "https://download.docker.com/win/static/stable/x86_64/docker-20.10.8.zip" -$script:rancherDesktopUrl = "https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.1.1/Rancher.Desktop.Setup.1.1.1.exe" +$script:rancherDesktopVersion = "1.1.1" +$script:rancherDesktopInstallerName = "Rancher.Desktop.Setup.$script:rancherDesktopVersion" +$script:rancherDesktopInstallerHash = "DD3D52501963FD1757E8D0B972DEDA264AFE38D8F0EF3383AAA5B1BD6B6C0747" +$script:rancherDesktopUrl = "https://github.com/rancher-sandbox/rancher-desktop/releases/download/v$script:rancherDesktopVersion/$script:rancherDesktopInstallerName.exe" $script:wslVpnKitUrl = "https://github.com/sakai135/wsl-vpnkit/releases/download/v0.3.1/wsl-vpnkit.tar.gz" $script:restartRequired = $false $script:bashProfilePath = "C:\Users\$env:UserName\.bash_profile" @@ -214,10 +217,19 @@ function IsDockerDesktopInstalled function InstallRancherDesktop { Write-Host "Installing Rancher Desktop..." -ForegroundColor Blue - Invoke-WebRequest $script:rancherDesktopUrl -OutFile "Rancher.Desktop.Setup.1.1.1.exe" - .\Rancher.Desktop.Setup.1.1.1.exe - $setupId = (Get-Process Rancher.Desktop.Setup.1.1.1).id 2> $null + if(!(Test-Path -Path "$script:rancherDesktopInstallerName.exe") -or (Get-FileHash -Algorithm SHA256 "$script:rancherDesktopInstallerName.exe").Hash -ne "$script:rancherDesktopInstallerHash") + { + Invoke-WebRequest $script:rancherDesktopUrl -OutFile "$script:rancherDesktopInstallerName.exe" + if((Get-FileHash -Algorithm SHA256 "$script:rancherDesktopInstallerName.exe").Hash -ne "$script:rancherDesktopInstallerHash") + { + Write-Host "Checksum validation of Rancher Desktop installer failed." -ForegroundColor Red + exit 1 + } + } + Invoke-Expression ".\$script:rancherDesktopInstallerName.exe" + + $setupId = (Get-Process $script:rancherDesktopInstallerName).id 2> $null Wait-Process -Id $setupId From d9758ae7115925d01a418fd148c69e0f79c91186 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 17:27:28 +0200 Subject: [PATCH 11/12] Update install.ps1 --- install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index b8b21fa..5650f0d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -263,7 +263,7 @@ function ActivateWslVpnkit Add-Content $script:bashProfilePath "" } - Write-Host "VPN tool activated." -ForegroundColor Green + Write-Host "VPN support successfully installed." -ForegroundColor Green } From a2f5d186b536781280e6c642246ccfa0336cbdc9 Mon Sep 17 00:00:00 2001 From: albertdb Date: Tue, 3 May 2022 17:32:45 +0200 Subject: [PATCH 12/12] Update README.asciidoc --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index f73b140..7ec3330 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -20,7 +20,7 @@ To install it, clone the repository and run `install.ps1` with the desired flags .\install.ps1 -Alias -VPN -WindowsContainers ``` -*or right-click on the install script and select "Run with PowerShell"*, as it defaults to the above flags if run that way. +*or right-click on the install script and select "Run with PowerShell"*, it will default to the above flags. IMPORTANT: You may be asked to reboot your computer. This happens when you do not have the required Windows features already enabled. If so, relaunch installation process after restart.