# Add Pinscope to a Linux machine (Raspberry Pi, gateway)

Pinscope gives a local web interface on the machine a secure address, sends its journal, memory, load, temperature and disk to the Pinscope dashboard, and delivers update files to a command you choose. It is an agent installed as a systemd service. Full docs: https://pinscope.dev/docs/linux

## Steps

1. The project key. The user copies it from the dashboard: their project, tab **Connect a device**. Do not write it into scripts or files that are committed.
2. On the machine, with the local web port to expose as the last number (80 if unsure):
   ```
   curl -fsSL https://pinscope.dev/install.sh | sudo sh -s psk_... 80
   ```
   It builds the agent there (installing a compiler first on Debian, Ubuntu and Raspberry Pi OS if needed), installs the service `pinscope-agent` and prints the device's address. Running it again updates the agent or changes the key.
3. Optional, in `/etc/pinscope-agent.env`, then `sudo systemctl restart pinscope-agent`:
   - `PINSCOPE_LOGS=journalctl -f -o cat -u my-service` to send a service's log;
   - `PINSCOPE_UPDATE=/usr/local/bin/install-update` to take updates: the agent saves the uploaded file and runs that command with its path; exit status 0 counts as installed. Write the install command only if the user asks for updates, and show it to them.

## Check

- `systemctl status pinscope-agent` shows it running, and `journalctl -u pinscope-agent` shows `online`.
- The machine appears in the dashboard under Devices.

## Rules

- Never invent a project key and never write the user's key into a file that is committed. Ask the user for it, and keep it where the steps below say. A key is `psk_` followed by 24 letters, digits, `-` or `_`, 28 characters in all; if the one you are given is not, ask again.
- Change as little as you can: add Pinscope, do not restructure the project, rename files or touch unrelated code.
- Do not add a TLS library, certificates or port forwarding. Pinscope makes one outbound connection to `connect.pinscope.dev` on TCP port 443 and encrypts it itself.
- Do not edit Pinscope's own source; configure it.
- When you are done, tell the user exactly what you changed and what they still have to do (enter the key, flash, upload the firmware for updates).
