Skip to content
Back to search

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.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/reolink--reolink-cli/badge.svg)](/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

i

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)

  1. {
  2. "name": "reolink-cli",
  3. "description": "Reolink camera operator plugin for Claude Code",
  4. "owner": {
  5. "name": "Reolink"
  6. },
  7. "plugins": [
  8. {
  9. "name": "reolink-cli",
  10. "description": "Operate Reolink cameras locally via reolink-cli: discover, login, inspect, configure, preview, snapshot, and control PTZ/light/audio/detection/recording.",
  11. "version": "0.21.0",
  12. "source": "./",
  13. "author": {
  14. "name": "Reolink"
  15. }
  16. }
  17. ]
  18. }
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)

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

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.