From 3c9762fb98c53d4efcd09acaa4c175af67def5ee Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 20:53:10 -0400 Subject: [PATCH 1/9] update getZiti.pws for other platforms that just windows... --- quickstart/docker/image/getZiti.ps1 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 230425023..1f146fb92 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -18,9 +18,31 @@ None. If "dot sourced" this script will add the resultant directory to your path .EXAMPLE PS> . .\getZiti.ps1 #> +Add-Type -AssemblyName System.Runtime.InteropServices + +$osDescription = [System.Runtime.InteropServices.RuntimeInformation]::OSDescription +$osArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture +$frameworkDescription = [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription + +$arch=$osArchitecture.ToString().ToLower() +if($arch -match "x64") { + $arch = "amd64" +} + +if($osDescription.ToLower() -match "windows") { + $matchFilter="ziti-windows-$arch" +} elseif($osDescription.ToLower() -match "darwin") { + $matchFilter="ziti-darwin-$arch" +} elseif($osDescription.ToLower() -match "linux") { + $matchFilter="ziti-linux-$arch" +} else { + Write-Error "An error occurred. os not detected from osDescription: $osDescription" + return +} + $latestFromGitHub=(irm https://api.github.com/repos/openziti/ziti/releases/latest) $version=($latestFromGitHub.tag_name) -$zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "ziti-windows.*zip"} +$zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*zip"} $downloadUrl=($zitidl.browser_download_url) $name=$zitidl.name $defaultFolder="$env:USERPROFILE\.ziti\bin" From c26b910fbfc55d608dddb7fb13763ac3c9eec058 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:06:09 -0400 Subject: [PATCH 2/9] portable home directory in powershell --- quickstart/docker/image/getZiti.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 1f146fb92..7a9633463 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -45,8 +45,9 @@ $version=($latestFromGitHub.tag_name) $zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*zip"} $downloadUrl=($zitidl.browser_download_url) $name=$zitidl.name -$defaultFolder="$env:USERPROFILE\.ziti\bin" -$toDir=$(Read-Host "Where folder should be used for ziti? [default: ${defaultfolder}]") +$homeDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) +$defaultFolder="$homeDirectory\.ziti\bin" +$toDir=$(Read-Host "Where should ziti be installed? [default: ${defaultfolder}]") if($toDir.Trim() -eq "") { $toDir=("${defaultfolder}") } From cb6e71f82fced5e0d451defb5432ce5c0fc73fbf Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:09:22 -0400 Subject: [PATCH 3/9] use path separator for platform --- quickstart/docker/image/getZiti.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 7a9633463..5f10d1ea9 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -39,20 +39,20 @@ if($osDescription.ToLower() -match "windows") { Write-Error "An error occurred. os not detected from osDescription: $osDescription" return } - +$pathSeparator = [System.IO.Path]::PathSeparator $latestFromGitHub=(irm https://api.github.com/repos/openziti/ziti/releases/latest) $version=($latestFromGitHub.tag_name) $zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*zip"} $downloadUrl=($zitidl.browser_download_url) $name=$zitidl.name $homeDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) -$defaultFolder="$homeDirectory\.ziti\bin" +$defaultFolder="$homeDirectory${pathSeparator}.ziti${pathSeparator}bin" $toDir=$(Read-Host "Where should ziti be installed? [default: ${defaultfolder}]") if($toDir.Trim() -eq "") { $toDir=("${defaultfolder}") } -$zipFile="${toDir}\${name}" +$zipFile="${toDir}${pathSeparator}${name}" if($(Test-Path -Path $zipFile -PathType Leaf)) { Write-Output "The file has already been downloading. No need to download again" } else { @@ -66,10 +66,10 @@ if($(Test-Path -Path $zipFile -PathType Leaf)) { $ProgressPreference=$SavedProgressPreference } -Expand-Archive -Path $zipFile -DestinationPath "${toDir}\${version}" -ErrorAction SilentlyContinue +Expand-Archive -Path $zipFile -DestinationPath "${toDir}${pathSeparator}${version}" -ErrorAction SilentlyContinue Write-Output " " -Write-Output "Extracted binaries to ${toDir}\${version}\ziti" +Write-Output "Extracted binaries to ${toDir}${pathSeparator}${version}${pathSeparator}ziti" Write-Output " " $addToPath=$(Read-Host "Would you like to add ziti to this session's path? [default: Y]") if($addToPath.Trim() -eq "") { @@ -77,6 +77,6 @@ if($addToPath.Trim() -eq "") { } if($addToPath -ilike "y*") { - $env:Path+=";${toDir}\${version}" + $env:Path+=";${toDir}${pathSeparator}${version}" Write-Output "ziti added to your path!" } \ No newline at end of file From 9bdfed5fdfdb10e2bca9e083cbde5e7f5c91b884 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:11:07 -0400 Subject: [PATCH 4/9] direcotry/path separator... matters --- quickstart/docker/image/getZiti.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 5f10d1ea9..824873ef4 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -39,7 +39,7 @@ if($osDescription.ToLower() -match "windows") { Write-Error "An error occurred. os not detected from osDescription: $osDescription" return } -$pathSeparator = [System.IO.Path]::PathSeparator +$pathSeparator = [System.IO.Path]::DirectorySeparatorChar $latestFromGitHub=(irm https://api.github.com/repos/openziti/ziti/releases/latest) $version=($latestFromGitHub.tag_name) $zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*zip"} From 46a10e6efdaa68db124c27733f8b101869c230ef Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:14:05 -0400 Subject: [PATCH 5/9] not all are .zip --- quickstart/docker/image/getZiti.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 824873ef4..5a67d0112 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -42,7 +42,7 @@ if($osDescription.ToLower() -match "windows") { $pathSeparator = [System.IO.Path]::DirectorySeparatorChar $latestFromGitHub=(irm https://api.github.com/repos/openziti/ziti/releases/latest) $version=($latestFromGitHub.tag_name) -$zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*zip"} +$zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*"} $downloadUrl=($zitidl.browser_download_url) $name=$zitidl.name $homeDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) From 4c333c2d27f542aeabad2f3ac2994bf450f5824e Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:26:56 -0400 Subject: [PATCH 6/9] fix it for macos --- quickstart/docker/image/getZiti.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 5a67d0112..f60fb44e2 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -32,7 +32,8 @@ if($arch -match "x64") { if($osDescription.ToLower() -match "windows") { $matchFilter="ziti-windows-$arch" } elseif($osDescription.ToLower() -match "darwin") { - $matchFilter="ziti-darwin-$arch" + $matchFilter="ziti-darwin-amd64" + #todo: replace $arch some day } elseif($osDescription.ToLower() -match "linux") { $matchFilter="ziti-linux-$arch" } else { From 08c9d72e0635ee60f60796f6327c9c5effd3de07 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:48:50 -0400 Subject: [PATCH 7/9] getting dir/path separator and path all sorted and tar vs expand-archive --- quickstart/docker/image/getZiti.ps1 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index f60fb44e2..6a14aca1c 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -40,20 +40,21 @@ if($osDescription.ToLower() -match "windows") { Write-Error "An error occurred. os not detected from osDescription: $osDescription" return } -$pathSeparator = [System.IO.Path]::DirectorySeparatorChar +$dirSeparator = [System.IO.Path]::DirectorySeparatorChar +$pathSeparator = [System.IO.Path]::PathSeparator $latestFromGitHub=(irm https://api.github.com/repos/openziti/ziti/releases/latest) $version=($latestFromGitHub.tag_name) $zitidl=($latestFromGitHub).assets | where {$_.browser_download_url -Match "$matchFilter.*"} $downloadUrl=($zitidl.browser_download_url) $name=$zitidl.name $homeDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) -$defaultFolder="$homeDirectory${pathSeparator}.ziti${pathSeparator}bin" +$defaultFolder="$homeDirectory${dirSeparator}.ziti${dirSeparator}bin" $toDir=$(Read-Host "Where should ziti be installed? [default: ${defaultfolder}]") if($toDir.Trim() -eq "") { $toDir=("${defaultfolder}") } -$zipFile="${toDir}${pathSeparator}${name}" +$zipFile="${toDir}${dirSeparator}${name}" if($(Test-Path -Path $zipFile -PathType Leaf)) { Write-Output "The file has already been downloading. No need to download again" } else { @@ -67,10 +68,16 @@ if($(Test-Path -Path $zipFile -PathType Leaf)) { $ProgressPreference=$SavedProgressPreference } -Expand-Archive -Path $zipFile -DestinationPath "${toDir}${pathSeparator}${version}" -ErrorAction SilentlyContinue +if($osDescription.ToLower() -match "windows") { + Expand-Archive -Path $zipFile -DestinationPath "${toDir}${dirSeparator}${version}" -ErrorAction SilentlyContinue +} else { + $env:LC_ALL = "en_US.UTF-8" + mkdir "${toDir}${dirSeparator}${version}" + tar -xvf $zipFile -C "${toDir}${dirSeparator}${version}" +} Write-Output " " -Write-Output "Extracted binaries to ${toDir}${pathSeparator}${version}${pathSeparator}ziti" +Write-Output "Extracted binaries to ${toDir}${dirSeparator}${version}${dirSeparator}ziti" Write-Output " " $addToPath=$(Read-Host "Would you like to add ziti to this session's path? [default: Y]") if($addToPath.Trim() -eq "") { @@ -78,6 +85,6 @@ if($addToPath.Trim() -eq "") { } if($addToPath -ilike "y*") { - $env:Path+=";${toDir}${pathSeparator}${version}" + $env:PATH+="$pathSeparator${toDir}${dirSeparator}${version}" Write-Output "ziti added to your path!" } \ No newline at end of file From 1fbb7980c9b53d34e243fd9b62be33c137783ba0 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:55:49 -0400 Subject: [PATCH 8/9] add -p for non-ms oses --- quickstart/docker/image/getZiti.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 6a14aca1c..80c4cc8d8 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -58,7 +58,7 @@ $zipFile="${toDir}${dirSeparator}${name}" if($(Test-Path -Path $zipFile -PathType Leaf)) { Write-Output "The file has already been downloading. No need to download again" } else { - mkdir "${toDir}" -ErrorAction SilentlyContinue + mkdir -p "${toDir}" -ErrorAction SilentlyContinue Write-Output "Downloading file " Write-Output " from: ${downloadUrl} " Write-Output " to: ${zipFile}" @@ -72,7 +72,7 @@ if($osDescription.ToLower() -match "windows") { Expand-Archive -Path $zipFile -DestinationPath "${toDir}${dirSeparator}${version}" -ErrorAction SilentlyContinue } else { $env:LC_ALL = "en_US.UTF-8" - mkdir "${toDir}${dirSeparator}${version}" + mkdir -p "${toDir}${dirSeparator}${version}" tar -xvf $zipFile -C "${toDir}${dirSeparator}${version}" } From 8e4d7d985e2bf4882db1275e69df90a5d9a9f256 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sun, 1 Oct 2023 22:15:01 -0400 Subject: [PATCH 9/9] make mkdir more generic for other os'es --- quickstart/docker/image/getZiti.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstart/docker/image/getZiti.ps1 b/quickstart/docker/image/getZiti.ps1 index 80c4cc8d8..1a0c2af32 100644 --- a/quickstart/docker/image/getZiti.ps1 +++ b/quickstart/docker/image/getZiti.ps1 @@ -58,7 +58,7 @@ $zipFile="${toDir}${dirSeparator}${name}" if($(Test-Path -Path $zipFile -PathType Leaf)) { Write-Output "The file has already been downloading. No need to download again" } else { - mkdir -p "${toDir}" -ErrorAction SilentlyContinue + mkdir -p "${toDir}" Write-Output "Downloading file " Write-Output " from: ${downloadUrl} " Write-Output " to: ${zipFile}" @@ -87,4 +87,4 @@ if($addToPath.Trim() -eq "") { if($addToPath -ilike "y*") { $env:PATH+="$pathSeparator${toDir}${dirSeparator}${version}" Write-Output "ziti added to your path!" -} \ No newline at end of file +}