Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add install.ps1 for windows #1567

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions hack/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# PowerShell script to download and install Daytona binary

# Determine architecture
$architecture = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { "amd64" } else { "arm64" }

# Define version and download URL
$version = if ($env:DAYTONA_SERVER_VERSION) { $env:DAYTONA_SERVER_VERSION } else { "latest" }
$baseUrl = if ($env:DAYTONA_SERVER_DOWNLOAD_URL) { $env:DAYTONA_SERVER_DOWNLOAD_URL } else { "https://download.daytona.io/daytona" }
$destination = if ($env:DAYTONA_PATH) { $env:DAYTONA_PATH } else { "$env:APPDATA\bin\daytona" }
$downloadUrl = "$baseUrl/$version/daytona-windows-$architecture.exe"

Write-Host "Installing Daytona..."

Write-Host "" # Empty line

# Display installation directory
if ($env:DAYTONA_PATH) {
Write-Host "Using custom installation directory: $destination"
}
else {
Write-Host "Default installation directory: $destination"
Write-Host "You can override this by setting the DAYTONA_PATH environment variable."
}
Write-Host "" # Empty line
# Create destination directory if it doesn't exist
try {
if (!(Test-Path -Path $destination)) {
Write-Host "Creating installation directory at $destination"
New-Item -ItemType Directory -Force -Path $destination -ErrorAction Stop | Out-Null
Write-Host "" # Empty line
}
}
catch {
Write-Error "Failed to create installation directory: $_"
exit 1
}
# File to download
$outputFile = "$destination\daytona.exe"

# Download the file with progress using Invoke-WebRequest
try {
Write-Host "Downloading Daytona binary from $downloadUrl"

Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile -UseBasicParsing -ErrorAction Stop

Write-Host "" # Empty line
Write-Host "Download complete!"
}
catch {
Write-Error "Failed to download Daytona binary: $_"
exit 1
}
Write-Host "" # Empty line
# Set executable permissions
try {
Write-Host "Setting executable permissions for Daytona binary..."
Set-ItemProperty -Path $outputFile -Name IsReadOnly -Value $false
[System.IO.File]::SetAttributes($outputFile, 'Normal')
}
catch {
Write-Error "Failed to set executable permissions: $_"
exit 1
}
Write-Host "" # Empty line
# Add to PATH if not already present
try {
if (-not ($env:Path -split ';' | ForEach-Object { $_.TrimEnd('\') } | Where-Object { $_ -eq $destination })) {
Write-Host "Adding $destination to PATH..."
[System.Environment]::SetEnvironmentVariable("Path", "$env:Path;$destination", [System.EnvironmentVariableTarget]::User)
Write-Host "PATH updated successfully!"
}
}
catch {
Write-Error "Failed to update PATH: $_"
exit 1
}

Write-Host "" # Empty line

# Confirm installation
if (Test-Path $outputFile) {
Write-Host "Daytona has been successfully installed to $destination"
Write-Host "You can now use 'daytona' from the command line."
}
else {
Write-Error "Daytona installation failed."
exit 1
}
Write-Host "" # Empty line
Loading