# FuzzyShare CLI installer for Windows PowerShell. Usage: irm https://fuzzyshare.com/install.ps1 | iex # # Downloads fuzzy.exe from https://fuzzyshare.com, checks its SHA-256 against https://fuzzyshare.com/dl/checksums.txt, # installs it to $env:FUZZY_INSTALL_DIR (default %LOCALAPPDATA%\fuzzyshare\bin) and adds that # directory to your user PATH. No administrator rights are needed. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' function Install-FuzzyShare { $base = 'https://fuzzyshare.com' $name = 'fuzzy-windows-amd64.exe' if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { Write-Host 'Note: this is an ARM64 machine; the amd64 build runs under emulation.' } [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $dir = $env:FUZZY_INSTALL_DIR if (-not $dir) { $dir = $env:SISO_INSTALL_DIR } # the name from before the rename if (-not $dir) { $dir = Join-Path $env:LOCALAPPDATA 'fuzzyshare\bin' } New-Item -ItemType Directory -Force -Path $dir | Out-Null $tmp = Join-Path ([IO.Path]::GetTempPath()) ('fuzzy-install-' + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Force -Path $tmp | Out-Null try { Write-Host "Downloading $name from $base" Invoke-WebRequest -UseBasicParsing -Uri "$base/dl/$name" -OutFile (Join-Path $tmp $name) Invoke-WebRequest -UseBasicParsing -Uri "$base/dl/checksums.txt" -OutFile (Join-Path $tmp 'checksums.txt') $want = $null foreach ($line in Get-Content (Join-Path $tmp 'checksums.txt')) { $parts = $line -split '\s+', 2 if ($parts.Count -eq 2 -and $parts[1].TrimStart('*') -eq $name) { $want = $parts[0].ToLower(); break } } if (-not $want) { throw "checksums.txt has no entry for $name" } $got = (Get-FileHash -Algorithm SHA256 -Path (Join-Path $tmp $name)).Hash.ToLower() if ($want -ne $got) { throw "checksum mismatch for $name (expected $want, got $got); nothing was installed" } Write-Host "Checksum verified (sha256 $got)" $dest = Join-Path $dir 'fuzzy.exe' # a running fuzzy.exe cannot be overwritten but can be renamed: move it aside first if (Test-Path $dest) { Remove-Item "$dest.old" -Force -ErrorAction SilentlyContinue Move-Item -Force $dest "$dest.old" } Copy-Item -Force (Join-Path $tmp $name) $dest Write-Host "Installed $dest" & $dest version | Select-Object -First 1 } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') $onPath = $false if ($userPath) { $onPath = ($userPath -split ';') -contains $dir } if (-not $onPath) { $newPath = if ($userPath) { "$userPath;$dir" } else { $dir } [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') $env:Path = "$env:Path;$dir" Write-Host "Added $dir to your user PATH. Open a new terminal for other windows to see it." } # Remember this server so 'fuzzy login' only asks for the access key. An existing choice is kept, # and a failure here never fails the install. try { & $dest server --if-unset --no-check $base *> $null } catch { } $saved = '' try { $saved = (& $dest server 2>$null | Out-String).Trim() } catch { } Write-Host '' Write-Host 'Next step:' if ($saved -eq $base) { Write-Host ' fuzzy login' } else { Write-Host " fuzzy login --url $base" } Write-Host 'No account yet? Create one (it prints your key once and saves it for you):' if ($saved -eq $base) { Write-Host ' fuzzy register --name "Your Name" --email you@example.com' } else { Write-Host " fuzzy register --url $base --name `"Your Name`" --email you@example.com" } Write-Host "Later, 'fuzzy update' brings the CLI up to date from this server." } Install-FuzzyShare