Files
rclone-dropbox-bisync/windows/bootstrap.ps1
T
f-denkena f517cbd7ed install: DataStorage D:\Dropbox, create workdir, git bootstrap
Windows bootstrap.ps1 and Linux install.sh clone public Gitea repos,
build the fork, enable logon + 15-min bisync.
2026-09-10 00:38:07 +02:00

102 lines
4.1 KiB
PowerShell

# rclone-dropbox-bisync Windows setup
# Paths: D: (volume label DataStorage) \Dropbox and \rclone-bisync
# Paste into PowerShell, or: irm <raw-url>/windows/bootstrap.ps1 | iex
$ErrorActionPreference = 'Stop'
$GitBase = 'https://git.denkena-consulting.com/f-denkena'
$PackRepo = "$GitBase/rclone-dropbox-bisync.git"
$RcloneRepo = "$GitBase/rclone.git"
$Src = Join-Path $env:LOCALAPPDATA 'rclone-dropbox-bisync\src'
$Dest = Join-Path $env:LOCALAPPDATA 'rclone-dropbox-bisync'
$Dropbox = 'D:\Dropbox'
$Workdir = 'D:\rclone-bisync'
function Ensure-Cmd($Name, $WingetId) {
if (Get-Command $Name -ErrorAction SilentlyContinue) { return }
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
throw "Need $Name on PATH (or winget to install $WingetId)"
}
winget install -e --id $WingetId --accept-package-agreements --accept-source-agreements
$env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' +
[Environment]::GetEnvironmentVariable('Path', 'User')
}
Ensure-Cmd git Git.Git
Ensure-Cmd go GoLang.Go
New-Item -ItemType Directory -Force -Path $Src, (Join-Path $Dest 'bin') | Out-Null
if (-not (Test-Path (Join-Path $Src 'packaging\.git'))) {
git clone --depth 1 $PackRepo (Join-Path $Src 'packaging')
} else {
git -C (Join-Path $Src 'packaging') pull --ff-only
}
if (-not (Test-Path (Join-Path $Src 'rclone\.git'))) {
git clone --depth 1 --branch bisync-delta-list $RcloneRepo (Join-Path $Src 'rclone')
} else {
git -C (Join-Path $Src 'rclone') fetch origin bisync-delta-list
git -C (Join-Path $Src 'rclone') checkout bisync-delta-list
git -C (Join-Path $Src 'rclone') pull --ff-only
}
Write-Host 'Building rclone (forked)...'
Push-Location (Join-Path $Src 'rclone')
$env:CGO_ENABLED = '0'
go build -trimpath -o (Join-Path $Dest 'bin\rclone.exe') .
Pop-Location
Write-Host 'Building rclone-bisyncd...'
Push-Location (Join-Path $Src 'packaging\cmd\rclone-bisyncd')
go build -trimpath -o (Join-Path $Dest 'bin\rclone-bisyncd.exe') .
Pop-Location
Copy-Item -Force (Join-Path $Src 'packaging\windows\tray.ps1') (Join-Path $Dest 'tray.ps1')
if (-not (Test-Path 'D:\')) { throw 'D: is missing (expected DataStorage volume)' }
if (-not (Test-Path $Dropbox)) { throw "Dropbox folder not found: $Dropbox" }
New-Item -ItemType Directory -Force -Path $Workdir | Out-Null
$testFile = Join-Path $Dropbox 'RCLONE_TEST'
if (-not (Test-Path $testFile)) { New-Item -ItemType File -Path $testFile | Out-Null }
$cfgPath = Join-Path $Dest 'config.json'
@{
enabled = $true
path1 = $Dropbox
path2 = 'dropbox:'
workdir = $Workdir
interval_minutes = 15
rclone = (Join-Path $Dest 'bin\rclone.exe')
check_filename = 'RCLONE_TEST'
} | ConvertTo-Json | Set-Content -Encoding UTF8 $cfgPath
$env:RCLONE_BISYNC_CONFIG = $cfgPath
$bin = Join-Path $Dest 'bin'
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if ($userPath -notlike "*$bin*") {
[Environment]::SetEnvironmentVariable('Path', "$bin;$userPath", 'User')
}
$run = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'
$tray = Join-Path $Dest 'tray.ps1'
New-ItemProperty -Path $run -Name 'rclone-dropbox-bisync-tray' -PropertyType String -Force `
-Value "powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$tray`"" | Out-Null
# Sync at logon and every 15 minutes
$daemon = Join-Path $Dest 'bin\rclone-bisyncd.exe'
schtasks /Create /F /TN 'rclone-dropbox-bisync-startup' /SC ONLOGON /RL LIMITED /TR "`"$daemon`" --once" | Out-Null
schtasks /Create /F /TN 'rclone-dropbox-bisync' /SC MINUTE /MO 15 /TR "`"$daemon`" --once" /ST 00:00 | Out-Null
Start-Process powershell.exe -WindowStyle Hidden -ArgumentList @(
'-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $tray
)
Start-Process $daemon -ArgumentList '--once' -WindowStyle Hidden
Write-Host @"
Configured:
path1 $Dropbox (D: DataStorage)
workdir $Workdir
path2 dropbox:
startup ONLOGON + tray
interval 15 min
Put RCLONE_TEST on the Dropbox remote as well (rclone copy $testFile dropbox:RCLONE_TEST).
rclone remote 'dropbox:' must already exist in rclone.conf.
"@