Add portable flash-drive installer
- build-release.ps1: builds Docker image, saves to tar, bundles everything into dist\ ready to copy to a flash drive - installer/install.ps1: checks WSL2, Docker Desktop, loads image (or builds from source as fallback), prompts for photo/data paths, writes docker-compose.override.yml, starts container, creates desktop shortcut - installer/uninstall.ps1: stops container, optionally removes image and data, removes shortcut and app directory - installer/dupfinder-start-stop.ps1: start/stop/restart/open helper copied to target machine during install; desktop shortcut uses -Action open which polls until the app is responsive before launching browser Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
71
installer/dupfinder-start-stop.ps1
Normal file
71
installer/dupfinder-start-stop.ps1
Normal file
@@ -0,0 +1,71 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Start, stop, restart DupFinder, or open it in the browser.
|
||||
.PARAMETER Action
|
||||
start | stop | restart | open (default: open)
|
||||
.EXAMPLE
|
||||
.\dupfinder-start-stop.ps1 -Action open
|
||||
.\dupfinder-start-stop.ps1 -Action stop
|
||||
#>
|
||||
param(
|
||||
[ValidateSet("start","stop","restart","open")]
|
||||
[string]$Action = "open"
|
||||
)
|
||||
|
||||
$ConfigFile = "C:\ProgramData\DupFinder\dupfinder.conf"
|
||||
|
||||
if (-not (Test-Path $ConfigFile)) {
|
||||
Write-Error "DupFinder is not installed. Run install.ps1 first."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read config
|
||||
$conf = @{}
|
||||
Get-Content $ConfigFile | ForEach-Object {
|
||||
if ($_ -match '^(.+?)=(.+)$') { $conf[$Matches[1]] = $Matches[2] }
|
||||
}
|
||||
|
||||
$ComposeDir = $conf["COMPOSE_DIR"]
|
||||
$AppPort = $conf["APP_PORT"]
|
||||
$ComposeYml = "$ComposeDir\docker-compose.yml"
|
||||
$OverrideYml = "$ComposeDir\docker-compose.override.yml"
|
||||
$Url = "http://localhost:$AppPort"
|
||||
|
||||
function Invoke-Compose([string]$cmd) {
|
||||
& docker compose -f $ComposeYml -f $OverrideYml $cmd.Split(" ")
|
||||
}
|
||||
|
||||
switch ($Action) {
|
||||
"start" {
|
||||
Write-Host "Starting DupFinder..."
|
||||
Invoke-Compose "up -d --pull never"
|
||||
}
|
||||
"stop" {
|
||||
Write-Host "Stopping DupFinder..."
|
||||
Invoke-Compose "stop"
|
||||
}
|
||||
"restart" {
|
||||
Write-Host "Restarting DupFinder..."
|
||||
Invoke-Compose "restart"
|
||||
}
|
||||
"open" {
|
||||
# Ensure container is running
|
||||
$running = docker ps --filter "name=dup-finder" --format "{{.Names}}" 2>$null
|
||||
if (-not $running) {
|
||||
Write-Host "Starting DupFinder..."
|
||||
Invoke-Compose "up -d --pull never"
|
||||
}
|
||||
# Poll until responsive (up to 15s)
|
||||
$tries = 0
|
||||
while ($tries -lt 15) {
|
||||
try {
|
||||
$r = Invoke-WebRequest -Uri $Url -UseBasicParsing -TimeoutSec 1 -ErrorAction Stop
|
||||
break
|
||||
} catch { }
|
||||
Start-Sleep 1
|
||||
$tries++
|
||||
}
|
||||
Start-Process $Url
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user