# ntfy-bridge Windows installer # Run: powershell -ExecutionPolicy Bypass -File install.ps1 param( [string]$ConfigPath = "ntfy-bridge.yaml" ) $ErrorActionPreference = "Stop" Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan Write-Host "║ ntfy-bridge Windows installer ║" -ForegroundColor Cyan Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" # Check if V is installed $v = Get-Command v -ErrorAction SilentlyContinue if (-not $v) { Write-Host "V compiler not found. Downloading..." $vUrl = "https://github.com/vlang/v/releases/download/weekly.2024.32/v_windows.zip" $vZip = "$env:TEMP\v_windows.zip" $vDir = "$env:LOCALAPPDATA\v" Invoke-WebRequest -Uri $vUrl -OutFile $vZip Expand-Archive -Path $vZip -DestinationPath $vDir -Force Remove-Item $vZip $env:PATH = "$vDir\v;$env:PATH" Write-Host "V installed to $vDir" } # Install NSSM (required for Windows service) $nssmPath = "$env:ProgramFiles\ntfy-bridge\nssm.exe" if (-not (Test-Path $nssmPath)) { Write-Host "Downloading NSSM (Non-Sucking Service Manager)..." $nssmUrl = "https://nssm.cc/release/nssm-2.24.zip" $nssmZip = "$env:TEMP\nssm.zip" $nssmDir = "$env:TEMP\nssm_extract" Invoke-WebRequest -Uri $nssmUrl -OutFile $nssmZip Expand-Archive -Path $nssmZip -DestinationPath $nssmDir -Force # Find nssm.exe in the extracted folder (it's in a win64 subfolder) $nssmExe = Get-ChildItem -Path $nssmDir -Recurse -Name "nssm.exe" | Select-Object -First 1 if (-not $nssmExe) { Write-Error "Could not find nssm.exe in the downloaded archive." exit 1 } $extractedNssm = Join-Path $nssmDir $nssmExe New-Item -ItemType Directory -Force -Path "$env:ProgramFiles\ntfy-bridge" | Out-Null Copy-Item -Force $extractedNssm $nssmPath Remove-Item $nssmZip Remove-Item -Recurse -Force $nssmDir Write-Host "NSSM installed to $nssmPath" } # Build Write-Host "Building ntfy-bridge..." v -prod -o ntfy-bridge.exe . # Copy to install directory $installDir = "$env:ProgramFiles\ntfy-bridge" New-Item -ItemType Directory -Force -Path $installDir | Out-Null Copy-Item -Force ntfy-bridge.exe $installDir\ Copy-Item -Force dashboard.html $installDir\ # Copy example config if not exists if (-not (Test-Path "$installDir\ntfy-bridge.yaml")) { Copy-Item ntfy-bridge.example.yaml "$installDir\ntfy-bridge.yaml" Write-Host "" Write-Host " ⚠️ Edit $installDir\ntfy-bridge.yaml to configure your sources!" -ForegroundColor Yellow } # Install as Windows service (via NSSM) Write-Host "Installing as Windows service..." & "$installDir\ntfy-bridge.exe" --install-service --config "$installDir\ntfy-bridge.yaml" 2>&1 | Write-Host Write-Host "" Write-Host "Done! ntfy-bridge is installed and running as a Windows service." -ForegroundColor Green Write-Host "" Write-Host " Install dir: $installDir" Write-Host " Config: $installDir\ntfy-bridge.yaml" Write-Host " Dashboard: http://localhost:9090/" Write-Host " Health: http://localhost:9090/health" Write-Host "" Write-Host " Service commands:" Write-Host " nssm status ntfy-bridge" Write-Host " nssm stop ntfy-bridge" Write-Host " nssm start ntfy-bridge" Write-Host " nssm remove ntfy-bridge confirm (uninstall)" Write-Host "" Write-Host " Logs: C:\ProgramData\ntfy-bridge\service.log"