-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
68 lines (54 loc) · 2.28 KB
/
install.ps1
File metadata and controls
68 lines (54 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# ln.bot CLI installer for Windows (PowerShell)
# Usage: iwr -useb https://ln.bot/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "lnbotdev/cli"
$Binary = "lnbot.exe"
$InstallDir = "$env:LOCALAPPDATA\lnbot"
# Detect architecture
$Arch = if ([Environment]::Is64BitOperatingSystem) {
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" }
} else {
Write-Error "32-bit Windows is not supported"; exit 1
}
Write-Host "Detecting platform... windows/$Arch" -ForegroundColor Green
# Get latest release
$Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
$Tag = $Release.tag_name
$Version = $Tag.TrimStart("v")
Write-Host "Latest version: $Tag" -ForegroundColor Green
# Download
$Archive = "lnbot_windows_$Arch.zip"
$Url = "https://github.com/$Repo/releases/download/$Tag/$Archive"
$TmpDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "lnbot-install-$(Get-Random)")
Write-Host "Downloading $Url..." -ForegroundColor Green
try {
Invoke-WebRequest -Uri $Url -OutFile (Join-Path $TmpDir $Archive) -UseBasicParsing
} catch {
Write-Error "Download failed. Check https://github.com/$Repo/releases"
exit 1
}
# Extract
Write-Host "Extracting..." -ForegroundColor Green
Expand-Archive -Path (Join-Path $TmpDir $Archive) -DestinationPath $TmpDir -Force
# Install
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
Move-Item -Path (Join-Path $TmpDir $Binary) -Destination (Join-Path $InstallDir $Binary) -Force
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
$env:Path = "$env:Path;$InstallDir"
Write-Host "Added $InstallDir to PATH" -ForegroundColor Yellow
}
# Cleanup
Remove-Item -Recurse -Force $TmpDir
Write-Host ""
Write-Host "lnbot $Version installed to $InstallDir\$Binary" -ForegroundColor Green
Write-Host ""
Write-Host " Get started:" -ForegroundColor Green
Write-Host " lnbot init" -ForegroundColor Green
Write-Host " lnbot wallet create --name agent01" -ForegroundColor Green
Write-Host ""
Write-Host " Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow