Files
clip-sync/install.ps1
T

89 lines
3.4 KiB
PowerShell

# clip-sync install.ps1
# One-liner install on Windows (PowerShell):
#
# irm https://git.dracodev.net/Projets/clip-sync/raw/branch/main/install.ps1 | iex
#
# Detects architecture, downloads the binary, installs to
# %LOCALAPPDATA%\clip-sync\bin, adds it to PATH, and creates a default config.
$ErrorActionPreference = 'Stop'
$Version = if ($env:CLIP_SYNC_VERSION) { $env:CLIP_SYNC_VERSION } else { 'v0.2.0' }
$Repo = 'https://git.dracodev.net/Projets/clip-sync'
# ── Detect architecture ───────────────────────────────────────────────
$arch = switch ($env:PROCESSOR_ARCHITECTURE) {
'AMD64' { 'amd64' }
'ARM64' { 'arm64' }
'x86' { 'amd64' } # 32-bit Windows runs the amd64 binary under WoW64/emulation
default { throw "clip-sync: unsupported architecture: $env:PROCESSOR_ARCHITECTURE" }
}
$binName = "clip-sync-windows-$arch.exe"
$url = "$Repo/releases/download/$Version/$binName"
$installDir = Join-Path $env:LOCALAPPDATA 'clip-sync\bin'
$exePath = Join-Path $installDir 'clip-sync.exe'
# ── Download ──────────────────────────────────────────────────────────
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Write-Host "clip-sync: downloading $url"
try {
Invoke-WebRequest -Uri $url -OutFile $exePath -UseBasicParsing
} catch {
Write-Host "clip-sync: download failed. Try building from source:" -ForegroundColor Red
Write-Host " git clone $Repo && cd clip-sync && make install"
throw
}
# ── Add to PATH ───────────────────────────────────────────────────────
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if ($userPath -split ';' -notcontains $installDir) {
[Environment]::SetEnvironmentVariable('Path', "$userPath;$installDir", 'User')
$env:Path += ";$installDir"
Write-Host "clip-sync: added $installDir to PATH (restart your terminal to use it)"
} else {
$env:Path += ";$installDir"
}
# ── Create default config ─────────────────────────────────────────────
$configDir = Join-Path $env:USERPROFILE '.config\clip-sync'
$configFile = Join-Path $configDir 'peers.toml'
if (-not (Test-Path $configFile)) {
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
@'
# clip-sync peers configuration
# %USERPROFILE%\.config\clip-sync\peers.toml
[daemon]
port = 9137
poll_interval_ms = 500
# discovery = true # enable mDNS auto-discovery of peers
# notify = true # enable desktop notifications
# sync_images = true # sync images from the clipboard (PNG)
# receive_files = true # accept incoming file transfers
[security]
# shared_key = "..." # generate with: clip-sync --generate-key
# Add your peers here:
# [[peers]]
# name = "example"
# addr = "192.168.1.x:9137"
'@ | Set-Content -Path $configFile -Encoding UTF8
Write-Host "clip-sync: created default config at $configFile"
}
Write-Host ""
Write-Host "clip-sync: installation complete!" -ForegroundColor Green
Write-Host " 1. Edit $configFile to add your peers"
Write-Host " 2. Run: clip-sync"
Write-Host ""
Write-Host " For service installation, see README.md"