diff --git a/install.ps1 b/install.ps1 index 831d5a7..8c04e4c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,11 +4,14 @@ One-liner (PowerShell): irm https://git.armoredarmadillo.com/brockdarnold/eve-watcher/raw/branch/main/install.ps1 | iex - Paste it ONCE and you're done forever: it git-clones the watcher repo into + Paste it ONCE and you're done forever: it puts the watcher repo in %USERPROFILE%\eve-watcher, runs update.py, and update.py registers a Windows Scheduled Task that auto-updates + restarts the watchers at every logon and once a day. You never have to install or update again. - Your config.ini (webhook + OCR snip) is gitignored, so updates never touch it. + + Safe to re-run: if the folder already exists (even from the old non-git + installer) it is converted into a git clone in place, keeping your config.ini + (webhook + OCR snip). config.ini is gitignored, so updates never touch it. #> $ErrorActionPreference = "Stop" $repo = "https://git.armoredarmadillo.com/brockdarnold/eve-watcher.git" @@ -16,19 +19,39 @@ $dir = Join-Path $env:USERPROFILE "eve-watcher" function Need($cmd, $hint) { if (-not (Get-Command $cmd -ErrorAction SilentlyContinue)) { - Write-Warning "$cmd not found. $hint" - exit 1 + Write-Warning "$cmd not found. $hint"; exit 1 } } -Need git "Install it: winget install --id Git.Git -e" +function GitOk($desc) { + if ($LASTEXITCODE -ne 0) { Write-Warning "git failed: $desc"; exit 1 } +} + +Need git "Install it: winget install --id Git.Git -e (then re-run)" Need python "Install Python 3 from https://www.python.org (check 'Add to PATH'), then re-run." if (Test-Path (Join-Path $dir ".git")) { - Write-Host "eve-watcher already cloned at $dir — pulling latest." - git -C $dir pull --ff-only -} else { + Write-Host "eve-watcher already cloned at $dir - pulling latest." + git -C $dir pull --ff-only; GitOk "pull" +} +elseif (Test-Path $dir) { + # Folder exists but isn't a git repo (old baked installer). Convert it in place, + # force-replacing the old scripts with the repo versions; config.ini is gitignored + # so it's left exactly as-is. + Write-Host "Existing install found at $dir - converting to a git clone (keeping config.ini)..." + git -C $dir init -q; GitOk "init" + if (-not (git -C $dir remote)) { git -C $dir remote add origin $repo } + else { git -C $dir remote set-url origin $repo } + GitOk "remote" + git -C $dir fetch -q origin; GitOk "fetch" + git -C $dir checkout -f -B main origin/main; GitOk "checkout" +} +else { Write-Host "Cloning eve-watcher into $dir ..." - git clone $repo $dir + git clone $repo $dir; GitOk "clone" +} + +if (-not (Test-Path (Join-Path $dir "update.py"))) { + Write-Warning "update.py missing after setup - something went wrong. Aborting."; exit 1 } Set-Location $dir @@ -36,5 +59,5 @@ python update.py Write-Host "" Write-Host "Installed at $dir." -Write-Host "Auto-update + auto-start is now a Scheduled Task (logon + daily) — nothing else to do." +Write-Host "Auto-update + auto-start is now a Scheduled Task (logon + daily) - nothing else to do." Write-Host "One-time (per PC) for OCR hold alerts: cd $dir ; python eve_orehold_watcher.py --snip"