PowerShell/scripts/install-syncthing.ps1
2025-05-18 11:05:52 +02:00

39 lines
1.1 KiB
PowerShell

<#
.SYNOPSIS
Installs Syncthing
.DESCRIPTION
This PowerShell script installs Syncthing on your computer.
Syncthing is a continuous file synchronization program. See https://syncthing.net for details.
.EXAMPLE
PS> ./install-syncthing.ps1
⏳ Installing Syncthing from WinGet...
...
.LINK
Author: Markus Fleschutz | License: CC0
.NOTES
https://github.com/fleschutz/PowerShell
#>
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) {
"⏳ Installing Syncthing..."
& sudo apt install syncthing
} else {
"⏳ Installing Syncthing from WinGet..."
& winget install --id Syncthing.Syncthing --accept-package-agreements --accept-source-agreements
"⏳ Starting Syncthing as daemon..."
Start-Process -NoNewWindow "$env:LOCALAPPDATA\Microsoft\WinGet\Links\syncthing.exe"
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✅ Syncthing installed successfully in $($elapsed)s."
" Web interface: http://127.0.0.1:8384 (open by: <Ctrl> <click>)"
" Sync folder at: ~/Sync/ (execute: cd-sync.ps1)"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0])"
exit 1
}