reolink-cli
Reolink camera operator plugin for Claude Code
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/reolink--reolink-cli)HTML
<a href="/listings/reolink--reolink-cli"><img src="/api/listings/reolink--reolink-cli/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
These steps run a script from the network that findsafeskills does not scan.
Claude Code — no Node required
/plugin marketplace add reolink/reolink-cli /plugin install reolink-cli@reolink-cli
Install the CLI and gateway first with the command-line installer below, then install the plugin. The plugin provides the skill and MCP registration; it does not install the CLI binaries or start the gateway. Start the gateway separately, then just talk: *“show me the front door camera”*, *“point the back-yard camera left”*, *“blink the porch spotlight 3 times”*.
Other agents — requires [Node.js](https://nodejs.org)
Codex, Cursor, Gemini, Copilot, OpenCode and 70+ others:
npx skills@latest add reolink/reolink-cli
Pick `reolink-cli` and the agents to install it into. `npx skills` installs the skill files; it does not install the CLI binaries or start the gateway. Install those separately with the command-line installer below.
Command line only — no Node required
Installs `reolink-cli` + `reolink-gateway` to `~/.local/bin` (no `sudo`) and initializes config:
# macOS / Linux curl -fsSL https://raw.githubusercontent.com/reolink/reolink-cli/main/install.sh | sh
# Windows — works from PowerShell or the Command Prompt powershell -NoProfile -Command "iwr https://raw.githubusercontent.com/reolink/reolink-cli/main/install.ps1 -UseBasicParsing | iex"
Both installers verify the download before installing anything — see [Install and verify](#install-and-verify) for exactly what they do.
Windows x64 requires the [Microsoft Visual C++ runtime](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist).
**Upgrading:** `reolink-cli self-update --yes` on macOS/Linux. On Windows, re-run the installer (a running `.exe` cannot replace itself).
<details> <summary>Prefer a downloadable archive?</summary>
Grab the archive for your platform from the [latest Release](https://github.com/reolink/reolink-cli/releases/latest), [verify it](#install-and-verify), extract, and run the bundled installer:
tar -xzf reolink-cli-*.tar.gz && cd reolink-cli-*/ && ./install.sh # Windows: extract the .zip and run .\install.ps1
The archive is self-contained: binaries + the skill/plugin + installer + `THIRD-PARTY-LICENSES.txt`.
</details>
<details> <summary>Uninstall</summary>
reolink-cli setup --uninstall # add --purge to also delete config and the camera registry npx skills remove reolink-cli # if you installed the skill with npx
Claude Code users: also run `/plugin uninstall reolink-cli`.
</details>
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 18 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- {
- "name": "reolink-cli",
- "description": "Reolink camera operator plugin for Claude Code",
- "owner": {
- "name": "Reolink"
- },
- "plugins": [
- {
- "name": "reolink-cli",
- "description": "Operate Reolink cameras locally via reolink-cli: discover, login, inspect, configure, preview, snapshot, and control PTZ/light/audio/detection/recording.",
- "version": "0.21.0",
- "source": "./",
- "author": {
- "name": "Reolink"
- }
- }
- ]
- }
README.md · README · 389 lines · 2 findings marked
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- <div align="center">
- <img src="docs/banner.svg" alt="Reolink CLI" width="320">
- **A local-first command-line tool for operating Reolink cameras — JSON by default, with a built-in MCP server and a cross-agent skill so AI agents drive the same core.**
- 
- 
- 
- </div>
- ---
- Control Reolink cameras over your **local network** — no cloud account, no app.
- Script it with `jq`, or let an AI agent drive it in plain language.
- ```console
- $ reolink-cli --camera front-door info | jq '.data | {model, firmware, name}'
- {
- "model": "Reolink Video Doorbell",
- "firmware": "v3.0.0.6696_26062799",
- "name": "Front Door"
- }
- ```
- > **What this repository is.** The official distribution point for the prebuilt
- > `reolink-cli` binaries (proprietary, royalty-free EULA — see [License](#license)),
- > plus the agent skill, plugin manifests and installers (Apache 2.0). The CLI
- > source code is not published here.
- ## Does it work with my camera?
- It talks to Reolink devices directly over your LAN:
- - **IP cameras and video doorbells** with a LAN address, wired or Wi-Fi
- - **NVRs and the Home Hub** — `device expand <nvr>` registers one entry per
- channel, which is also the only way to reach a battery camera paired to a hub
- - **Battery cameras**, on your Wi-Fi or through a Home Hub — a sleeping camera
- can take several seconds to answer the first command
- Features differ by model. Ask the camera rather than guessing:
- ```bash
- reolink-cli --camera porch capabilities
- ```
- An operation the model does not implement fails with a clear "device does not
- support" error, never silently.
- ## Highlights
- - 🔍 **Discovery** — LAN broadcast, plus bulk `device import`
- - 🎥 **Live media** — `preview play`, file/stdout capture, batch capture, JPEG snapshot
- - 🕹️ **PTZ** — pan/tilt/zoom, presets, patrol, guard, autotrack, real timed jog
- - 💡 **Lights** — IR, spotlight (with native **blink**), white-LED, status LED
- - 🎚️ **Video encoder** — resolution, frame rate, bit rate, H.264/H.265, GOP per stream
- - 📢 **Siren** — sound / silence the built-in siren on demand
- - 🧠 **Detection** — motion + AI (person / vehicle / dog_cat / package)
- - 📼 **Recording & storage** — schedule, SD/HDD status, VOD search & download
- - 🔔 **Events** — query/stream + a declarative rule engine (`events monitor`)
- - 🗣️ **Two-way audio** — talkback / TTS straight to the camera speaker
- - 🌐 **Stream URLs** — RTSP / RTMP / FLV for Frigate, Home Assistant, go2rtc, VLC
- - 🤖 **AI-native** — built-in MCP stdio server + cross-agent operator skill
- - 🧩 **Fleet-aware** — camera & tag selectors, local session daemon for a fast control plane
- The authoritative command list comes from the binary: `reolink-cli --help`,
- `reolink-cli <command> --help`, or `reolink-cli features` for a machine-readable
- manifest.
- For a terminal walkthrough, see the [Operator Guide](docs/operator-guide.md).
- For command-oriented navigation, see the [CLI Reference](docs/cli-reference.md).
- <details>
- <summary>Command overview</summary>
- | Area | Commands | What you can do |
- |---|---|---|
- | **Setup & registry** | `init`, `device`, `config`, `doctor`, `setup` | Scaffold config, register/import cameras, tag them, health-check the install |
- | **Connect & inspect** | `ping`, `login`, `info`, `capabilities`, `status`, `benchmark` | Reach a camera, read model/firmware/serial, list what the model supports, measure round-trip latency |
- | **Discovery** | `discover` | Find cameras on the LAN (broadcast) |
- | **Live media** | `preview`, `snapshot`, `stream` | Play or capture live video, grab a JPEG, print RTSP/RTMP/FLV URLs |
- | **Image & encoder** | `image`, `encode`, `osd` | Flip/mirror, encoder settings per stream, on-screen name/time overlay |
- | **Lights** | `light` | IR / night vision, spotlight (with **blink**), white-LED, status LED |
- | **Audio** | `audio` | Volume, alarm mute, **siren**, quick replies, two-way talkback / TTS |
- | **PTZ** | `ptz` | Pan / tilt / zoom, focus, presets, patrol, guard, autotrack, timed jog |
- | **Detection & events** | `detect`, `notify`, `events` | Motion + AI detection, push settings, query/stream events, rule engine |
- | **Recording & storage** | `record`, `vod`, `storage`, `log` | Recording schedule, VOD search & download, SD/HDD status, device logs |
- | **Privacy & users** | `privacy`, `users` | Privacy-mask regions, manage device accounts |
- | **Network** | `wifi` | Push a new SSID + PSK (pre-validated), auto-rediscover, update the registry |
- | **System** | `system` | Reboot |
- | **Gateway & tooling** | `gateway`, `mcp-server`, `plugin`, `cache`, `self-update` | Run the local gateway, expose MCP tools, maintain the skill cache, update the binaries |
- </details>
- ## Install
- ### Claude Code — no Node required
- ```text
- /plugin marketplace add reolink/reolink-cli
- /plugin install reolink-cli@reolink-cli
- ```
- Install the CLI and gateway first with the command-line installer below, then
- install the plugin. The plugin provides the skill and MCP registration; it does
- not install the CLI binaries or start the gateway. Start the gateway separately,
- then just talk: *“show me the front door camera”*, *“point the back-yard camera
- left”*, *“blink the porch spotlight 3 times”*.
- ### Other agents — requires [Node.js](https://nodejs.org)
- Codex, Cursor, Gemini, Copilot, OpenCode and 70+ others:
- ```bash
- npx skills@latest add reolink/reolink-cli
- ```
- Pick `reolink-cli` and the agents to install it into. `npx skills` installs the
- skill files; it does not install the CLI binaries or start the gateway. Install
- those separately with the command-line installer below.
- ### Command line only — no Node required
- Installs `reolink-cli` + `reolink-gateway` to `~/.local/bin` (no `sudo`) and
- initializes config:
- ```bash
- # macOS / Linux
- curl -fsSL https://raw.githubusercontent.com/reolink/reolink-cli/main/install.sh | sh
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 130 on GitHub
- ```
- ```powershell
- # Windows — works from PowerShell or the Command Prompt
- powershell -NoProfile -Command "iwr https://raw.githubusercontent.com/reolink/reolink-cli/main/install.ps1 -UseBasicParsing | iex"
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 135 on GitHub
- ```
- Both installers verify the download before installing anything — see
- [Install and verify](#install-and-verify) for exactly what they do.
- Windows x64 requires the [Microsoft Visual C++ runtime](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist).
- **Upgrading:** `reolink-cli self-update --yes` on macOS/Linux. On Windows,
- re-run the installer (a running `.exe` cannot replace itself).
- <details>
- <summary>Prefer a downloadable archive?</summary>
- Grab the archive for your platform from the
- [latest Release](https://github.com/reolink/reolink-cli/releases/latest),
- [verify it](#install-and-verify), extract, and run the bundled installer:
- ```bash
- tar -xzf reolink-cli-*.tar.gz && cd reolink-cli-*/ && ./install.sh
- # Windows: extract the .zip and run .\install.ps1
- ```
- The archive is self-contained: binaries + the skill/plugin + installer +
- `THIRD-PARTY-LICENSES.txt`.
- </details>
- <details>
- <summary>Uninstall</summary>
- ```bash
- reolink-cli setup --uninstall # add --purge to also delete config and the camera registry
- npx skills remove reolink-cli # if you installed the skill with npx
- ```
- Claude Code users: also run `/plugin uninstall reolink-cli`.
- </details>
- ## Quick start
- **1. Start the gateway.** Most commands go through a small local process that
- keeps camera sessions open, so repeated commands are fast. Leave it running in
- its own terminal (or under your service manager):
- ```bash
- reolink-cli gateway start --addr 127.0.0.1:9000
- ```
- **2. Tell the CLI where it is** — for this shell, or permanently by adding
- `gateway-addr = "127.0.0.1:9000"` to `config.toml` (`reolink-cli doctor` prints
- where that file lives):
- ```bash
- export REOLINK_GATEWAY_ADDR=127.0.0.1:9000
- ```
- Port 9000 already taken (Portainer, MinIO, …)? Use any free port in both places.
- **3. Find a camera, register it, use it:**
- ```bash
- reolink-cli discover # cameras on your LAN
- reolink-cli device add porch --host 192.0.2.41 --user admin
- reolink-cli --camera porch info
- reolink-cli --camera porch snapshot --file ./porch.jpg
- ```
- The interactive `device add` command prompts for the password without echoing
- it. For non-interactive scripts, pipe exactly one password line to
- `--password-stdin` and remove the variable afterwards:
- ```bash
- printf '%s\n' "$DEVICE_PASSWORD" |
- reolink-cli device add porch --host 192.0.2.41 --user admin --password-stdin
- unset DEVICE_PASSWORD
- ```
- `device list` also shows a few disabled example entries the installer wrote to
- illustrate the file format — `device remove <name>` clears them.
- Many cameras at once — credentials via the environment, never `--password`:
- ```bash
- export REOLINK_PASSWORD='<device-password>'
- reolink-cli --user admin device import
- unset REOLINK_PASSWORD
- ```
- `preview play` needs `ffplay` on `PATH` (or pass `--player`, or set
- `REOLINK_PLAYER`).
- ## Multi-device workflow
- Target selection stays explicit — there is no hidden “current device” state.
- | Selector | Meaning |
- |---|---|
- | `--camera <name>` | one registered device |
- | `--cameras <a,b,c>` | several registered devices |
- | `--tag <tag>` | every device carrying a tag |
- | `--all-devices` | the whole registry |
- | `--host <ip[:port]>` | an ad-hoc device by address |
- ```bash
- reolink-cli device list
- reolink-cli --tag outdoor device inventory --capabilities
- reolink-cli --tag outdoor snapshot # fan out across a tag group
- ```
- ## Frigate, Home Assistant, go2rtc, VLC
- Print a camera's stream URLs, read from its real port configuration:
- ```bash
- reolink-cli --camera porch stream url --kind rtsp,rtmp,flv --stream main,sub
- ```
- URLs omit credentials by default. `--with-auth` embeds
- `user:password@` in the URL for players that need it — treat that output as a
- password.
- ## AI agents & MCP
- Two ways in, both driving the same runtime as the CLI:
- For complete MCP setup, client configuration, target selection, security, and
- troubleshooting, see the [MCP Guide](docs/mcp-guide.md).
- - **The skill** — natural language. It teaches the agent the command surface and
- the safety rules, so you say *“point the driveway cam to preset 2, then take a
- snapshot”* or *“let me know if anyone shows up at the door tonight”*. The agent
- **never guesses device state** — it only reports what a command returned.
- - **The MCP server** — typed tool calls for tight automation loops. The Claude
- Code plugin already registers it. For any other MCP client:
- ```json
- "mcpServers": {
- "reolink-cli": {
- "command": "reolink-cli",
- "args": ["mcp-server"],
- "env": { "REOLINK_GATEWAY_ADDR": "127.0.0.1:9000" }
- }
- }
- ```
- JSON-RPC 2.0 over stdio; the gateway must be running, as for the CLI.
- ## Platform support
- Prebuilt binaries on each [Release](https://github.com/reolink/reolink-cli/releases):
- | OS | Architectures |
- |---|---|
- | macOS | arm64 (Apple Silicon) |
- | Linux (glibc) | x86_64, arm64 |
- | Linux (musl, static) | x86_64, arm64 — Alpine, Home Assistant OS, slim Docker images |
- | Linux 32-bit ARM | armv7 (Pi 2/3/4 on a 32-bit OS), armv6 (Pi 1 / Zero) — glibc 2.28+ |
- | Windows | x86_64 |
- The installers select the matching architecture and libc variant. For manual
- downloads, choose both values from the release asset name; see the
- [Operator Guide](docs/operator-guide.md) for host-specific notes.
- ## Security and privacy
- Use this tool only on cameras you own or are authorised to administer.
- `discover` and `ping` are for locating your own devices, not for sweeping
- networks you were not asked to work on. Snapshots, recordings and event history
- written to disk are personal data — protect them like the camera's own storage,
- and delete what you no longer need.
- - **The gateway binds `127.0.0.1` by default** and refuses browser
- cross-origin requests. `--addr 0.0.0.0:9000` exposes camera control to your
- whole LAN — do it deliberately.
- - **LAN-only build.** The public external package requires a camera LAN address
- and does not provide remote relay connectivity. `reolink-cli --version` shows
- `(external · LAN-only)`.
- - **Report vulnerabilities privately** — see [SECURITY.md](SECURITY.md), which
- also documents what the tool does by design.
- ### Safe credential handling
- - **Never pass `--password` on the command line** — it shows up in `ps` and
- your shell history. Use the interactive prompt, `--password-stdin`,
- `REOLINK_PASSWORD`, or register the camera once with `device add` and refer
- to it by name.
- - **Stored passwords are encrypted at rest** (AES-256-GCM) with a
- `credentials.key` kept next to the registry. Config files are owner-only
- (`0600`) and the CLI refuses to read them otherwise. **Back up the registry and
- its `credentials.key` as a pair** — neither works without the other. Details:
- [SECURITY.md → Stored credentials](SECURITY.md#stored-credentials).
- - **Credentials never go in a URL.** Gateway media endpoints use a session token
- that expires after 300 s of inactivity. The one exception is
- `stream url --with-auth`, which you ask for explicitly.
- - **Redact before sharing output** — it can contain UIDs, serial numbers, LAN
- addresses and stream URLs.
- ## Install and verify
- `install.sh` and `install.ps1` are plain text — read them before running. They:
- - download the latest release from `github.com` only
- - **verify it against `checksums/<tag>.sha256` committed to this repository's
- default branch**, never the checksum attached to the release, and abort on any
- mismatch or missing entry
- - install both `reolink-cli` and `reolink-gateway` to `~/.local/bin`
- (`%USERPROFILE%\.local\bin` on Windows) — no `sudo`, no system directories,
- no services
- - stop a running `reolink-gateway` only if it runs from that same prefix
- - overwrite previous binaries in that prefix; nothing else on disk is modified
- - add the prefix to your user `PATH` if it is missing (Windows)
- <a id="verifying-a-download"></a>
- ### Manual download verification
- ```bash
- tag=vX.Y.Z # the release you downloaded
- curl -fsSL -o CHECKSUMS \
- "https://raw.githubusercontent.com/reolink/reolink-cli/main/checksums/$tag.sha256"
- shasum -a 256 -c CHECKSUMS --ignore-missing # sha256sum -c on Linux
- ```
- Use this committed file, **not** the `SHA256SUMS` attached to the release:
- whoever can replace a release asset can regenerate the checksum beside it. This
- proves integrity, not who built the archive — [SECURITY.md](SECURITY.md#download-verification-what-it-proves-and-what-it-does-not)
- states exactly what it does and does not cover.
- ## Trademarks
- "Reolink" and the Reolink logo are trademarks of Reolink Innovation Limited.
- The Apache 2.0 licence covers the code and docs in this repository — it grants
- no rights to the Reolink name or logo. If you publish a fork, rename it and
- remove the marks; see [TRADEMARKS.md](TRADEMARKS.md).
- ## License
- - **This repository** — the skill, plugin manifests, installers and docs — is
- licensed under the **[Apache License 2.0](LICENSE)** (see also [NOTICE](NOTICE)).
- - **The prebuilt `reolink-cli` binaries** on the
- [Releases](https://github.com/reolink/reolink-cli/releases) page are
- **proprietary**, governed by the EULA bundled in each release archive. The
- CLI source is not published here.
- - **Third-party open-source components** bundled in the binaries are listed in
- `THIRD-PARTY-LICENSES.txt` inside each release archive.
- ## Container deployments
- See the [container deployment guide](docs/distribution-guide.md) for the
- version-pinned CLI/gateway image recipe, persistent data, desktop CLI/MCP
- launchers and the OpenClaw overlay. Build from verified external release
- artifacts; registry publication is a separate workflow. Native installation
- remains available through the installers above.
install.ps1 · Bundled script · 170 lines · 2 findings marked
- # reolink-cli one-line installer (Windows).
- #
- # From PowerShell or the Command Prompt:
- #
- # powershell -NoProfile -Command "iwr https://raw.githubusercontent.com/reolink/reolink-cli/main/install.ps1 -UseBasicParsing | iex"
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 5 on GitHub
- #
- # From PowerShell only (iwr/iex are PowerShell aliases; in cmd.exe this fails
- # with "'iwr' is not recognized", which does not hint at the cause):
- #
- # iwr https://raw.githubusercontent.com/reolink/reolink-cli/main/install.ps1 -UseBasicParsing | iex
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 10 on GitHub
- #
- # Runs on Windows PowerShell 5.1 and PowerShell 7.
- #
- # Downloads the latest release for Windows x64, installs it to
- # %USERPROFILE%\.local\bin, adds it to your user PATH, and initializes config.
- # For AI agents use `npx skills add reolink/reolink-cli` instead.
- $ErrorActionPreference = 'Stop'
- $Repo = if ($env:REOLINK_REPO) { $env:REOLINK_REPO } else { 'reolink/reolink-cli' }
- # NOT overridable, deliberately. Both the archive and the checksum used to come
- # from $Repo, so REOLINK_REPO moved the anchor along with the download and an
- # attacker-supplied repository validated its own archive (GHSA-65x2-w384-qp7j,
- # finding 2). A genuine mirror serves identical bytes and still passes; a fork
- # serving its own build no longer does.
- $ChecksumRepo = 'reolink/reolink-cli'
- $Prefix = if ($env:REOLINK_PREFIX) { $env:REOLINK_PREFIX } else { Join-Path $env:USERPROFILE '.local' }
- $Bin = Join-Path $Prefix 'bin'
- $headers = @{ 'User-Agent' = 'reolink-cli-install' }
- if ($env:GITHUB_TOKEN) { $headers['Authorization'] = "Bearer $($env:GITHUB_TOKEN)" }
- Write-Host "==> resolving latest release of $Repo"
- $rel = Invoke-RestMethod -UseBasicParsing -Headers $headers -Uri "https://api.github.com/repos/$Repo/releases/latest"
- $tag = $rel.tag_name
- if (-not $tag) { throw "could not resolve the latest release (public repo? set GITHUB_TOKEN if private)" }
- $ver = $tag.TrimStart('v')
- # Release archives carry the build flavour in the name so internal development
- # and customer (LAN-only) builds can never be mistaken for one another. Only
- # the external flavour is published here.
- $asset = "reolink-cli-$ver-external-windows-x86_64.zip"
- $tmp = Join-Path $env:TEMP ("reolink-install-" + [System.Guid]::NewGuid().ToString('N'))
- New-Item -ItemType Directory -Force -Path $tmp | Out-Null
- try {
- $zip = Join-Path $tmp $asset
- Write-Host "==> downloading $asset ($tag)"
- Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "https://github.com/$Repo/releases/download/$tag/$asset" -OutFile $zip
- # Verify against the checksums COMMITTED TO THE REPOSITORY, not the
- # SHA256SUMS attached to the release. A checksum from the same release can
- # only detect accidental corruption: whoever can replace the asset can
- # regenerate a matching SHA256SUMS in the same API call. A file on the
- # default branch is behind a reviewed pull request and permanent history;
- # checksums/<tag>.sha256 is committed there as part of each release, from
- # the machine that built it.
- #
- # Fail closed: no fallback to the release-attached SHA256SUMS, and a tag
- # with no committed checksum file aborts — so a fabricated release does
- # not install. This is an integrity check, not a signature: it proves the
- # archive is the one whose hash was committed to $ChecksumRepo, not who
- # built it.
- Write-Host "==> verifying checksum against $ChecksumRepo"
- $sumsPath = Join-Path $tmp "CHECKSUMS"
- try {
- Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "https://raw.githubusercontent.com/$ChecksumRepo/main/checksums/$tag.sha256" -OutFile $sumsPath
- } catch {
- throw "no committed checksum file for $tag (checksums/$tag.sha256 on the default branch of $ChecksumRepo). Either this release has not been synced yet, or the tag did not come from the release process. Refusing to install."
- }
- # Split on whitespace rather than regex-matching the line: the asset name
- # would otherwise be interpolated into a pattern, where one mis-escaped
- # character silently matches nothing and blocks every install.
- $expected = $null
- foreach ($line in Get-Content $sumsPath) {
- $parts = $line -split '\s+', 2
- if ($parts.Count -eq 2) {
- $name = $parts[1].Trim().TrimStart('*')
- if ($name -eq $asset) { $expected = $parts[0].Trim().ToLower(); break }
- }
- }
- if (-not $expected) { throw "checksums/$tag.sha256 has no entry for $asset - refusing to install" }
- $actual = (Get-FileHash -Path $zip -Algorithm SHA256).Hash.ToLower()
- if ($actual -ne $expected) {
- throw @"
- checksum mismatch for $asset
- expected $expected
- actual $actual
- The download does not match the checksum committed to $ChecksumRepo. Nothing was installed.
- A truncated or proxy-mangled download is the ordinary cause, so retrying is worth one attempt.
- If it fails again, stop and report it at https://github.com/$ChecksumRepo/security/advisories/new
- - do not work around it by pointing REOLINK_REPO elsewhere or downloading the archive by hand,
- which skips the only check that would have caught the problem.
- "@
- }
- Write-Host " ok ($expected)"
- # Refuse a hostile archive layout before unpacking (GHSA-65x2-w384-qp7j,
- # finding 3). Expand-Archive's own traversal behaviour has varied across
- # PowerShell versions, so the guarantee is made here instead of assumed.
- # Windows PowerShell 5.1 — `powershell.exe`, the default on Windows — does not
- # load this assembly until something asks for it, while PowerShell 7 has it
- # already. Without this line the type lookup below fails and the installer
- # aborts before touching anything, on the exact shell most users are running.
- # Harmless where it is already loaded.
- Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction SilentlyContinue
- $entries = [System.IO.Compression.ZipFile]::OpenRead($zip)
- try {
- $bad = $entries.Entries |
- Where-Object { $_.FullName -match '^([A-Za-z]:)?[\\/]' -or $_.FullName -match '(^|[\\/])\.\.([\\/]|$)' } |
- Select-Object -First 5 -ExpandProperty FullName
- } finally { $entries.Dispose() }
- if ($bad) { throw "archive contains absolute or parent-directory members - refusing to extract:`n$($bad -join "`n")" }
- $unpack = Join-Path $tmp 'unpack'
- New-Item -ItemType Directory -Force -Path $unpack | Out-Null
- Expand-Archive -Path $zip -DestinationPath $unpack -Force
- New-Item -ItemType Directory -Force -Path $Bin | Out-Null
- # Derived, not discovered. The archive always unpacks to one directory named
- # after itself; searching the tree for a filename lets an archive that
- # carries a second reolink-cli.exe decide which one gets installed and run.
- $root = Join-Path $unpack ([System.IO.Path]::GetFileNameWithoutExtension($asset))
- if (-not (Test-Path -LiteralPath $root -PathType Container)) {
- throw "archive does not unpack to $([System.IO.Path]::GetFileNameWithoutExtension($asset))\ - layout is not what this installer expects"
- }
- # Windows locks running .exe files, so Copy-Item -Force would fail with
- # "file in use". Stop any reolink process running from $Bin first.
- Get-Process -Name reolink-gateway,reolink-cli -ErrorAction SilentlyContinue |
- Where-Object { $_.Path -like (Join-Path $Bin '*') } |
- ForEach-Object { Write-Host "stopping $($_.Name) (pid $($_.Id))"; Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue }
- # Resolve each binary first and fail by name when it is absent. Piping
- # Get-ChildItem straight into Copy-Item silently does nothing on an empty
- # pipeline, so a malformed archive used to install nothing, exit 0, and only
- # surface later as `config init` failing to find a file it never mentions.
- # install.sh has always failed loudly here; this is the missing half.
- foreach ($exe in 'reolink-cli.exe', 'reolink-gateway.exe') {
- $src = Join-Path $root (Join-Path 'bin' $exe)
- if (-not (Test-Path -LiteralPath $src -PathType Leaf)) {
- throw "$exe is not at bin\$exe in the archive - refusing to guess"
- }
- # A reparse point here would copy whatever it targets, under a name we then
- # place on PATH. The archive ships regular files; anything else is not it.
- $item = Get-Item -LiteralPath $src -Force
- if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
- throw "bin\$exe in the archive is a reparse point - refusing to install"
- }
- Copy-Item -LiteralPath $src (Join-Path $Bin $exe) -Force
- }
- } finally {
- Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
- }
- # Add to user PATH if missing.
- $userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
- if ($userPath -notlike "*$Bin*") {
- [Environment]::SetEnvironmentVariable('Path', "$userPath;$Bin", 'User')
- $env:Path = "$env:Path;$Bin"
- Write-Host "added $Bin to your user PATH (restart the shell to pick it up everywhere)"
- }
- & (Join-Path $Bin 'reolink-cli.exe') config init 2>$null | Out-Null
- Write-Host ""
- Write-Host "installed reolink-cli + reolink-gateway to $Bin"
- & (Join-Path $Bin 'reolink-cli.exe') --version
- Write-Host ""
- Write-Host "next steps:"
- Write-Host " reolink-cli gateway start --addr 127.0.0.1:9000"
- Write-Host " reolink-cli device add front-door --host <camera-ip> --user admin"
- Write-Host " reolink-cli --camera front-door info"
install.sh · Bundled script · 278 lines · 1 finding marked
- #!/bin/sh
- # reolink-cli one-line installer (macOS / Linux).
- #
- # curl -fsSL https://raw.githubusercontent.com/reolink/reolink-cli/main/install.sh | sh
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 4 on GitHub
- #
- # Downloads the latest release binary for your platform, installs it to
- # ~/.local/bin, and initializes config. No AI agent needed — for agents, use
- # `npx skills add reolink/reolink-cli` instead (it fetches the binary for you).
- #
- # Env overrides: REOLINK_REPO=owner/repo, REOLINK_PREFIX=/install/root.
- set -eu
- REPO="${REOLINK_REPO:-reolink/reolink-cli}"
- # Where the checksum comes from is NOT overridable, and that is the whole point.
- #
- # Reported privately (GHSA-65x2-w384-qp7j, finding 2). Both the archive and the
- # checksum used to be fetched from $REPO, so pointing REOLINK_REPO at another
- # repository meant the archive was checked against *that* repository's own
- # committed checksums. Attacker supplies both halves, every check passes, and
- # the install reports "ok" with a hash it just accepted from the attacker.
- #
- # "You need shell access to set the variable, and then you have code execution
- # anyway" is not a rebuttal here. The override travels in text people copy: a
- # blog snippet, a Dockerfile, a CI job, a web page an AI agent is reading. The
- # danger was never that the variable exists; it was that it silently moved the
- # anchor along with the download, so a documented, apparently-verified path was
- # not verified against anything the project controls.
- #
- # A genuine mirror still works: mirroring means identical bytes, so the
- # canonical checksums match. What no longer works is a fork serving its own
- # build — which is exactly the case that must not silently pass.
- CHECKSUM_REPO="reolink/reolink-cli"
- PREFIX="${REOLINK_PREFIX:-$HOME/.local}"
- BIN="$PREFIX/bin"
- say() { printf '%s\n' "$*"; }
- die() { printf 'error: %s\n' "$*" >&2; exit 1; }
- command -v curl >/dev/null 2>&1 || die "curl is required"
- command -v tar >/dev/null 2>&1 || die "tar is required"
- os=$(uname -s); arch=$(uname -m)
- case "$os" in
- Darwin) os=darwin ;;
- Linux) os=linux ;;
- *) die "unsupported OS '$os' — see https://github.com/$REPO/releases" ;;
- esac
- case "$arch" in
- # `uname -m` answers for the *kernel*, and on ARM the two can disagree: a
- # 64-bit kernel with a 32-bit userland reports aarch64 while having no arm64
- # loader, so the arm64 archive cannot start at all. That is not a corner case
- # — it is the default on 32-bit Raspberry Pi OS from Bullseye onward, which
- # sets `arm_64bit=1`. `getconf LONG_BIT` and the loader on disk answer for the
- # userland, which is what actually has to run this. Measured: a 32-bit armhf
- # root has LONG_BIT=32 and no `ld-linux-aarch64.so.1`; a real arm64 root has
- # LONG_BIT=64 and does. Two probes because `getconf` is absent from some
- # minimal images.
- #
- # Hardware that can boot a 64-bit kernel is ARMv8 at least, so armv7 is the
- # right fallback here and armv6 never is.
- arm64|aarch64)
- if [ "$os" = linux ] && { [ "$(getconf LONG_BIT 2>/dev/null)" = 32 ] ||
- { [ ! -e /lib/ld-linux-aarch64.so.1 ] && [ -e /lib/ld-linux-armhf.so.3 ]; }; }; then
- arch=armv7
- else
- arch=arm64
- fi
- ;;
- x86_64|amd64) arch=x86_64 ;;
- # 32-bit ARM — a Raspberry Pi running a 32-bit OS on a 32-bit kernel too.
- # armv7 covers Pi 2/3/4; armv6 covers the Pi 1 and Zero, whose CPUs cannot
- # execute armv7 code at all, which is why these are two archives and not one.
- armv7l|armv7) arch=armv7 ;;
- armv6l|armv6) arch=armv6 ;;
- *) die "unsupported arch '$arch' — see https://github.com/$REPO/releases" ;;
- esac
- # macOS ships Apple Silicon only; Intel Macs are not supported.
- if [ "$os" = darwin ] && [ "$arch" = x86_64 ]; then
- die "macOS Intel (x86_64) is not supported — Apple Silicon (arm64) only. See https://github.com/$REPO/releases"
- fi
- # Alpine and the distributions built on it (Home Assistant OS most visibly) use
- # musl rather than glibc. The glibc archives do not merely run badly there, they
- # cannot load at all: `Error relocating ./reolink-cli: __res_init: symbol not
- # found`. Pick the statically linked musl archive instead.
- #
- # Two probes because either alone has a blind spot: the loader path is what
- # actually decides, but a container can carry musl without the usual filename,
- # and `ldd --version` prints "musl libc" on Alpine while exiting non-zero, so it
- # is read for its output and not its status. A glibc box that merely has musl
- # installed alongside would match and get the static archive, which runs there
- # too — the failure this ordering avoids is the one that leaves you unable to
- # start the binary at all.
- if [ "$os" = linux ]; then
- if [ -n "$(ls /lib/ld-musl-*.so.1 2>/dev/null)" ] ||
- { command -v ldd >/dev/null 2>&1 && ldd --version 2>&1 | grep -qi musl; }; then
- arch="${arch}-musl"
- fi
- fi
- # Optional bearer token (private repo only); public access is anonymous.
- #
- # The header goes to curl on **stdin**, never on the command line. argv is
- # world-readable through `ps`, so any other user on the machine could lift
- # GITHUB_TOKEN for as long as the request runs. `self_update.rs` already refuses
- # to do this and says why; this script was doing the opposite at three call
- # sites, in the same project, against the same threat.
- #
- # `printf | curl` rather than a heredoc on curl's own stdin: this script is
- # routinely run as `curl … | sh`, where the shell's stdin *is* the script. A
- # command that reads stdin there would eat the rest of the script.
- if [ -n "${GITHUB_TOKEN:-}" ]; then
- curl_gh() { printf 'Authorization: Bearer %s\n' "$GITHUB_TOKEN" | curl -H @- "$@"; }
- else
- curl_gh() { curl "$@"; }
- fi
- if [ "$REPO" != "$CHECKSUM_REPO" ]; then
- say "note: downloading from $REPO, but verifying against checksums committed to"
- say " $CHECKSUM_REPO. A mirror of the same artifacts passes; a fork serving"
- say " its own build will not."
- fi
- say "==> resolving latest release of $REPO"
- tag=$(curl_gh -fsSL -A reolink-cli-install \
- "https://api.github.com/repos/$REPO/releases/latest" \
- | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n1)
- [ -n "$tag" ] || die "could not resolve the latest release (is the repo public? set GITHUB_TOKEN if it is private)"
- ver="${tag#v}"
- # Release archives carry the build flavour in the name so internal development
- # and customer (LAN-only) builds can never be mistaken for one another. Only
- # the external flavour is published here.
- asset="reolink-cli-${ver}-external-${os}-${arch}.tar.gz"
- tmp=$(mktemp -d)
- trap 'rm -rf "$tmp"' EXIT INT TERM
- say "==> downloading $asset ($tag)"
- hint=""
- case "$arch" in
- *-musl) hint="
- musl archives start at v0.10.7; earlier releases published glibc builds only." ;;
- esac
- curl_gh -fSL -A reolink-cli-install \
- -o "$tmp/pkg.tar.gz" "https://github.com/$REPO/releases/download/$tag/$asset" \
- || die "download failed — see https://github.com/$REPO/releases$hint"
- # Verify the download against the checksums COMMITTED TO THE REPOSITORY, not the
- # SHA256SUMS attached to the release. The distinction is the trust boundary:
- # replacing a release asset takes one API call by any account with write access
- # and leaves no visible trace, and whoever can do that can regenerate a matching
- # SHA256SUMS in the same call — a checksum from the same release can therefore
- # only ever detect accidental corruption. A file on the default branch is behind
- # a reviewed pull request and permanent history. checksums/<tag>.sha256 is
- # committed there as part of each release, from the machine that built it.
- #
- # Fail closed, deliberately:
- # - no fallback to the release-attached SHA256SUMS — a fallback would hand an
- # attacker who controls the release a way to bypass this by making the
- # repository fetch fail;
- # - a tag with no committed checksum file aborts, so a fabricated release
- # (a tag that never went through the release process) does not install.
- #
- # This is an integrity check, not a signature. It proves the archive is the one
- # whose hash was committed to $CHECKSUM_REPO; it does not prove who built it.
- # An attacker who can commit to that repository's default branch can publish a
- # matching pair. Nothing here defends against that — see SECURITY.md.
- say "==> verifying checksum against $CHECKSUM_REPO"
- curl_gh -fsSL -A reolink-cli-install \
- -o "$tmp/CHECKSUMS" "https://raw.githubusercontent.com/$CHECKSUM_REPO/main/checksums/$tag.sha256" 2>/dev/null \
- || die "no committed checksum file for $tag (checksums/$tag.sha256 on the default branch of $CHECKSUM_REPO).
- Either this release has not been synced yet, or the tag did not come from the
- release process. Refusing to install."
- expected=$(sed -n "s/^\([0-9a-f]\{64\}\)[[:space:]]*[*]\{0,1\}$asset$/\1/p" "$tmp/CHECKSUMS" | head -n1)
- [ -n "$expected" ] || die "checksums/$tag.sha256 has no entry for $asset — refusing to install"
- if command -v shasum >/dev/null 2>&1; then
- actual=$(shasum -a 256 "$tmp/pkg.tar.gz" | awk '{print $1}')
- elif command -v sha256sum >/dev/null 2>&1; then
- actual=$(sha256sum "$tmp/pkg.tar.gz" | awk '{print $1}')
- else
- die "no shasum/sha256sum available to verify the download — install one, or download and verify manually from https://github.com/$REPO/releases"
- fi
- [ "$actual" = "$expected" ] || die "checksum mismatch for $asset
- expected $expected
- actual $actual
- The download does not match the checksum committed to $CHECKSUM_REPO.
- Nothing was installed.
- A truncated or proxy-mangled download is the ordinary cause, so retrying is
- worth one attempt. If it fails again, stop and report it at
- https://github.com/$CHECKSUM_REPO/security/advisories/new — do not work around
- it by pointing REOLINK_REPO elsewhere or downloading the archive by hand, which
- skips the only check that would have caught the problem."
- say " ok ($expected)"
- # Refuse a hostile archive layout before unpacking it (GHSA-65x2-w384-qp7j,
- # finding 3). Two separate problems, and only one of them was theoretical.
- #
- # Absolute and `..` members: current tar implementations already contain these
- # — BSD tar refuses `..` outright and exits non-zero, GNU/busybox tar strips the
- # prefix and keeps the file inside the destination — so neither escapes today.
- # The check is here so that guarantee comes from this script rather than from
- # whichever tar happens to be installed, and so the failure is a clear sentence
- # instead of "Path contains '..': Unknown error: -1".
- #
- # The one that was real: the binaries were located with
- # `find "$tmp" -type f -name reolink-cli | head -n1`, which searches the whole
- # extraction tree and takes whatever the walk reaches first. An archive carrying
- # a second `reolink-cli` in a directory sorting before the real one wins, and
- # that file is then chmod +x'd and executed. Confirmed by building such an
- # archive: the planted copy was selected. Both are fixed below — extract into a
- # dedicated subdirectory, and copy from the archive's documented layout instead
- # of searching for a name.
- say "==> checking archive layout"
- bad=$(tar -tzf "$tmp/pkg.tar.gz" | awk '
- /^\// || /(^|\/)\.\.(\/|$)/ { print; count++ }
- END { if (count == 0) exit 0 }' | head -n5)
- [ -z "$bad" ] || die "archive contains absolute or parent-directory members — refusing to extract:
- $bad"
- unpack="$tmp/unpack"
- mkdir -p "$unpack"
- tar -xzf "$tmp/pkg.tar.gz" -C "$unpack" || die "extraction failed"
- # The directory name is not discovered, it is derived: the release archive
- # always unpacks to a single directory named after itself, so we know what it
- # must be called before looking. Searching for it — even for "the first
- # top-level directory" — reintroduces the bug being fixed, because `find`
- # returns readdir order and an attacker picks the names. Anything else in the
- # archive is now simply never consulted.
- root="$unpack/${asset%.tar.gz}"
- [ -d "$root" ] || die "archive does not unpack to ${asset%.tar.gz}/ — layout is not what this installer expects"
- mkdir -p "$BIN"
- # Stop a running reolink-gateway installed under $BIN before overwriting, so the
- # upgrade takes effect (and the overwrite can't fail on a locked binary).
- if command -v pgrep >/dev/null 2>&1; then
- for _pid in $(pgrep -x reolink-gateway 2>/dev/null || true); do
- _exe=""
- [ -L "/proc/$_pid/exe" ] && _exe=$(readlink "/proc/$_pid/exe" 2>/dev/null || true)
- [ -z "$_exe" ] && command -v lsof >/dev/null 2>&1 && _exe=$(lsof -p "$_pid" 2>/dev/null | awk '$4=="txt"{print $NF; exit}')
- case "$_exe" in "$BIN"/*) say "==> stopping running reolink-gateway (pid $_pid)"; kill "$_pid" 2>/dev/null || true ;; esac
- done
- fi
- for b in reolink-cli reolink-gateway; do
- src="$root/bin/$b"
- [ -f "$src" ] || die "$b is not at bin/$b in the archive — refusing to guess"
- # A symlink here would copy whatever it points at, under a name we then make
- # executable. The archive ships regular files; anything else is not it.
- [ -L "$src" ] && die "bin/$b in the archive is a symlink — refusing to install"
- cp "$src" "$BIN/$b" && chmod 0755 "$BIN/$b"
- done
- "$BIN/reolink-cli" config init >/dev/null 2>&1 || true
- say ""
- say "installed reolink-cli + reolink-gateway to $BIN"
- "$BIN/reolink-cli" --version 2>/dev/null | sed 's/^/ /' || true
- case ":$PATH:" in
- *":$BIN:"*) ;;
- *) say ""; say "$BIN is not on your PATH yet — add it:"
- say " echo 'export PATH=\"$BIN:\$PATH\"' >> ~/.profile && export PATH=\"$BIN:\$PATH\"" ;;
- esac
- say ""
- say "next steps:"
- say " reolink-cli gateway start --addr 127.0.0.1:9000 &"
- say " reolink-cli device add front-door --host <camera-ip> --user admin"
- say " reolink-cli --camera front-door info"
- say ""
- say "using an AI agent (Claude Code / Codex / Cursor / …)? install the skill:"
- say " npx skills@latest add $REPO"
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.