Skip to content

Commit

Permalink
Improving windows installation script (#28)
Browse files Browse the repository at this point in the history
* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1

* Update install.ps1
  • Loading branch information
amit9192 authored Jul 10, 2024
1 parent d564b91 commit 95eed7a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ function Get-OS {
}

function Get-Arch {
if ((Get-WmiObject -Class Win32_ComputerSystem).SystemType -match '(x64)') {
$systemType = (Get-CimInstance -ClassName CIM_ComputerSystem).SystemType
if ($systemType -match 'x64') {
"amd64"
}
elseif ((Get-WmiObject -Class Win32_ComputerSystem).SystemType -match 'arm') {
elseif ($systemType -match 'ARM') {
"arm64"
}
elseif ((Get-WmiObject -Class Win32_ComputerSystem).SystemType -match '386') {
elseif ($systemType -match 'x86') {
"386"
}
}
Expand All @@ -40,16 +41,33 @@ function Get-Version {
return $response.name
}

function AddTo-Path{
param(
[string]$Dir
)
if (!(Test-Path $Dir) ){
Write-Warning "Supplied directory was not found!"
return
}
$PATH = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($PATH -notlike "*"+$Dir+"*" ){
[Environment]::SetEnvironmentVariable("PATH", "$PATH;$Dir", "User")
}
}

$os = Get-OS
$arch = Get-Arch
$downloadURL = Get-DownloadURL
$version = Get-Version
$installation_path = "$env:APPDATA\komodor"

Write-Host $os
Write-Host $arch
Write-Host $downloadURL
Write-Host "Downloading komocli package..."
Invoke-WebRequest -Uri $downloadURL -OutFile "komocli.exe"
Write-Host "Installing komocli..."
Move-Item -Path "komocli.exe" -Destination $env:APPDATA
[System.IO.Directory]::CreateDirectory($installation_path)
Move-Item -Path "komocli.exe" -Destination $installation_path
AddTo-Path($installation_path)
Write-Host "komocli installation completed!"

0 comments on commit 95eed7a

Please sign in to comment.