102 lines
5 KiB
PowerShell
102 lines
5 KiB
PowerShell
<#
|
|
install.ps1 - first-time bootstrap for the Eve watchers (Goliath + Adam's PC).
|
|
|
|
One-liner (PowerShell):
|
|
irm https://git.armoredarmadillo.com/brockdarnold/eve-watcher/raw/branch/main/install.ps1 | iex
|
|
|
|
Paste it ONCE. It auto-installs anything missing (Python, and Git if available),
|
|
downloads the watchers to %USERPROFILE%\eve-watcher (via git if possible, else a
|
|
plain zip - no git required), then runs update.py which installs deps + Tesseract,
|
|
starts the watchers, auto-detects the ore-hold readout (no manual snip), and sets
|
|
up logon + daily auto-update. Nothing to install or configure by hand.
|
|
|
|
Safe to re-run anytime. Your gitignored config.ini is never touched.
|
|
#>
|
|
$ErrorActionPreference = "Stop"
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
$repo = "https://git.armoredarmadillo.com/brockdarnold/eve-watcher.git"
|
|
$zipUrl = "https://git.armoredarmadillo.com/brockdarnold/eve-watcher/archive/main.zip"
|
|
$dir = Join-Path $env:USERPROFILE "eve-watcher"
|
|
$hook = "https://discord.com/api/webhooks/1515603432583598172/7g2A9Lfg1afbZGoxBENu9TpxSxE4zfpg16nRqE08qzyI3a0uttADL6wyJ2ERHRfsHlK9"
|
|
|
|
function Ping($text) {
|
|
try { Invoke-RestMethod -Uri $hook -Method Post -ContentType 'application/json' `
|
|
-UserAgent 'eve-watcher' -Body (@{content = $text} | ConvertTo-Json) `
|
|
-UseBasicParsing | Out-Null } catch {}
|
|
}
|
|
Ping("🔧 Installer started on **$env:COMPUTERNAME** (user $env:USERNAME)")
|
|
trap { Ping("❌ Installer FAILED on **$env:COMPUTERNAME**: $($_.Exception.Message)"); break }
|
|
|
|
function Have($c) { [bool](Get-Command $c -ErrorAction SilentlyContinue) }
|
|
function Refresh-Path {
|
|
$m = [Environment]::GetEnvironmentVariable("Path", "Machine")
|
|
$u = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
$env:Path = (@($m, $u) | Where-Object { $_ }) -join ';'
|
|
}
|
|
function Ensure-Tool($cmd, $wingetId) {
|
|
if (Have $cmd) { return $true }
|
|
if (Have winget) {
|
|
Write-Host "Installing $cmd (one-time, may prompt UAC)..."
|
|
try { winget install --id $wingetId -e --silent --accept-package-agreements --accept-source-agreements | Out-Null } catch {}
|
|
Refresh-Path # so the just-installed tool is found in THIS session
|
|
}
|
|
return (Have $cmd)
|
|
}
|
|
function Download-Zip {
|
|
Write-Host "Downloading watcher (no git needed)..."
|
|
$tmp = Join-Path $env:TEMP "eve-watcher.zip"
|
|
Invoke-WebRequest -Uri $zipUrl -OutFile $tmp -UseBasicParsing
|
|
$ex = Join-Path $env:TEMP ("ew_" + [guid]::NewGuid().ToString("N"))
|
|
Expand-Archive -Path $tmp -DestinationPath $ex -Force
|
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
Copy-Item -Path (Join-Path $ex "eve-watcher\*") -Destination $dir -Recurse -Force # archive has no config.ini
|
|
Remove-Item $tmp, $ex -Recurse -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# Pick up anything installed earlier in a now-stale session (e.g. git just installed
|
|
# by hand but PATH not refreshed - exactly the "git not found after installing" case).
|
|
Refresh-Path
|
|
|
|
# Python is the runtime - required. Git is optional (nice for updates/edits).
|
|
if (-not (Ensure-Tool python "Python.Python.3.12")) {
|
|
throw "Python is required and couldn't be auto-installed. Get it from https://www.python.org (check 'Add to PATH'), then re-run."
|
|
}
|
|
$haveGit = Ensure-Tool git "Git.Git"
|
|
|
|
$env:GIT_TERMINAL_PROMPT = "0" # fail fast instead of interactive y/n prompts
|
|
if ($haveGit) {
|
|
# Preserve local config across a clean re-clone.
|
|
$cfgTmp = $null
|
|
$cfgPath = Join-Path $dir "config.ini"
|
|
if (Test-Path $cfgPath) { $cfgTmp = Join-Path $env:TEMP "eve-config.bak"; Copy-Item $cfgPath $cfgTmp -Force }
|
|
# In-place git updates can lock .git pack files (Defender / EVE patcher scanning the
|
|
# drive) -> "Unlink of file ... failed". Avoid it: re-clone fresh into an empty dir.
|
|
if (Test-Path $dir) {
|
|
Get-Process git -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Recurse -Force $dir -ErrorAction SilentlyContinue
|
|
}
|
|
if (Test-Path $dir) {
|
|
Write-Warning "old folder is locked (AV/EVE scan?) - using zip instead."
|
|
Ping("git folder locked on **$env:COMPUTERNAME** - zip fallback")
|
|
Download-Zip
|
|
} else {
|
|
git clone --depth 1 $repo $dir
|
|
if ($LASTEXITCODE -ne 0) { Write-Warning "clone failed - using zip."; Download-Zip }
|
|
}
|
|
if ($cfgTmp -and (Test-Path $cfgTmp)) { Copy-Item $cfgTmp (Join-Path $dir "config.ini") -Force }
|
|
} else {
|
|
Write-Host "Git not available - installing without it (zip mode)."
|
|
Download-Zip
|
|
}
|
|
|
|
if (-not (Test-Path (Join-Path $dir "update.py"))) { throw "update.py missing after install - aborting." }
|
|
|
|
Set-Location $dir
|
|
python update.py
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Ping("⚠️ update.py exited $LASTEXITCODE on **$env:COMPUTERNAME** — likely a Microsoft-Store python stub (no real Python). Fix: winget install Python.Python.3.12, or disable the python.exe App-Execution-Alias.")
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Installed at $dir. Auto-start + daily auto-update are configured - nothing else to do."
|
|
Write-Host "Have your in-game Ore Hold window open so it can auto-calibrate the live % reader."
|