Files
duplicate-finder/installer/dupfinder-start-stop.ps1
tocmo 1d46b9945d 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>
2026-04-05 01:32:32 -04:00

72 lines
1.9 KiB
PowerShell

#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
}
}