> ## Documentation Index
> Fetch the complete documentation index at: https://docs.use.observer/llms.txt
> Use this file to discover all available pages before exploring further.

# Install script

> What use.observer/install.sh does on Linux and macOS, its flags, upgrades and exit codes.

The install script installs the agent binary on Linux or macOS and runs
it as a service. The AWS, Azure, Google Cloud and Oracle Cloud
templates run the same script on the VMs they create.

```bash theme={null}
curl -fsSL https://use.observer/install.sh | AGENT_KEY=obs_live_... sh
```

Without `AGENT_KEY` it asks for the key on the terminal and hides what
you type. To pass flags, add `-s --`:

```bash theme={null}
curl -fsSL https://use.observer/install.sh | AGENT_KEY=obs_live_... sh -s -- --version 1.8.4
```

Create the agent in Observer first (**Agents**, **Add agent**) to get
its key. Observer shows it once.

## What it does

1. Picks the binary for the machine: Linux x86\_64 or ARM64, macOS
   Apple silicon or Intel. Anything else exits with code 2; run the
   agent [with Docker](https://docs.use.observer/agent/quickstart/install-docker.md) there.
2. Downloads the binary and `SHA256SUMS.txt` from the agent's GitHub
   release (with `curl`, or `wget` when `curl` is missing) and checks
   the binary's SHA-256. On a mismatch it stops before writing
   anything.
3. Installs the binary to `/usr/local/bin/observer-agent`.
4. On Linux with systemd:

   * creates the system user `observer-agent`;
   * writes `/etc/observer-agent/agent.env` (mode 0600, readable by
     root only) with `AGENT_KEY`, `CLOUD_SERVER_URL` and
     `BUFFER_PATH=/var/lib/observer-agent/observer-agent-buffer.db`;
   * writes `/etc/systemd/system/observer-agent.service` and starts
     it.

   Run it as root, or as a user who can use `sudo`: it calls `sudo` for
   the steps that need root.
5. On macOS: clears the quarantine flag on the binary, writes the
   LaunchAgent `~/Library/LaunchAgents/use.observer.agent.plist` (mode
   0600\) and loads it. It starts at login and restarts if it exits.
   Logs go to `~/Library/Logs/observer-agent.log`. Run the script as
   yourself, not with `sudo`; it asks for your password when it needs
   root to install the binary.
6. On Linux without systemd (Alpine, most containers): installs the
   binary and prints the command to run it. On Alpine, install
   `gcompat` first (`apk add gcompat libstdc++`): the binary is built
   against glibc.

The unit and the plist are the same files the Add agent screen shows
for the systemd and launchd targets.

## Flags

| Flag | Default | What it does |
| - | - | - |
| `--version <X.Y.Z>` | latest | Install this release |
| `--cloud-url <url>` | `https://use.observer` | Observer address the agent reports to |
| `--prefix <dir>` | `/usr/local/bin` | Where the binary goes |
| `--no-service` | | Install the binary only |
| `--uninstall` | | Remove the binary, the service, its user and its files, including the local queue |
| `--dry-run` | | Print every action and write nothing |
| `--print-unit` | | Print the systemd unit (Linux) or launchd plist (macOS) it would write, then exit. The plist shows `${AGENT_KEY}` in place of the key |
| `-h`, `--help` | | Print the help |

## Upgrades

Run the same command again. It replaces the binary and restarts the
service.

Without `AGENT_KEY` it keeps the existing `agent.env` (or plist) as it
is, with the key, the Observer address and any variables you added.
With `AGENT_KEY` it writes the file again with only the key, the
Observer address and, on Linux, `BUFFER_PATH`: add your other
variables again afterwards. `--cloud-url` only takes effect when the
file is written, so pass it together with `AGENT_KEY`.

## Settings

On Linux, add [environment variables](https://docs.use.observer/agent/reference/environment-variables.md),
such as `PROMETHEUS_SERVER_URL` or the secrets that probes reference by
name, to `/etc/observer-agent/agent.env`, then restart:

```bash theme={null}
sudo systemctl restart observer-agent
```

On macOS, add them to the plist's `EnvironmentVariables` and load it
again, as in
[Install from a release binary](https://docs.use.observer/agent/quickstart/install-binary.md).

## Logs

* Linux: `journalctl -u observer-agent -f`
* macOS: `tail -f ~/Library/Logs/observer-agent.log`

## Exit codes

| Code | Meaning |
| - | - |
| 0 | Done |
| 1 | Error (download, checksum, permissions, invalid flag) |
| 2 | No binary for this OS or architecture |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.