# Self-hosted oak-agent

The `oak-agent` service can be self-hosted on `amd64` and `arm64` Linux machines. Self-hosted `oak-agent` requires Docker and
`systemd` to be installed on the host.

## Installation

Install the latest stable version by running:

```bash
curl -fsSL https://oakagent-releases.luxonis.com/self-hosted/stable/install-oak-agent.sh | sudo bash -s -- -y --password linux123
```

## Usage

Find the host where `oak-agent` is installed by running `oakctl device list`:

```sh
oakctl device list
+---+------------------+--------------------------------+----------------------------------------+------------------------+---------------+-------------------+
| # | Serial Number    | Device                         | Connection                             | OS                     | Agent Version | Setup             |
+=============================================================================================================================================================+
| 1 | 0e40028535f13370 | Raspberry Pi 5 Model B Rev 1.1 | 10.12.11.231, 10.12.102.35, 172.17.0.1 | Ubuntu 24.04.4 LTS     | 0.21.0        | Setup (unadopted) |
+---+------------------+--------------------------------+----------------------------------------+------------------------+---------------+-------------------+
```

Manage the service with `systemd`:

#### Enable oak-agent

```sh
sudo systemctl enable oak-agent
```

#### Disable oak-agent

```sh
sudo systemctl disable oak-agent
```

## Building OAK Apps without an OAK device

Self-hosted `oak-agent` can be used to build OAK Apps without an OAK4 device. This is useful for CI or for preparing `.oakapp`
packages on a separate Linux host.

If you want to install the built app on an OAK4 device afterward, the self-hosted agent must run on an `arm64` Linux machine.

### Example: Build the UVC C++ example on self-hosted oak-agent and install it on an OAK4 device

This example uses a `Raspberry Pi 5` as the self-hosted `oak-agent` host and an `OAK4` device as the deployment target.

Use the [installation command above](#Installation).

```sh
oakctl device list
+---+------------------+--------------------------------+----------------------------------------+------------------------+---------------+-------------------+
| # | Serial Number    | Device                         | Connection                             | OS                     | Agent Version | Setup             |
+=============================================================================================================================================================+
| 1 | 0e40028535f13370 | Raspberry Pi 5 Model B Rev 1.1 | 10.12.11.231, 10.12.102.35, 172.17.0.1 | Ubuntu 24.04.4 LTS     | 0.21.0        | Setup (unadopted) |
+---+------------------+--------------------------------+----------------------------------------+------------------------+---------------+-------------------+
| 2 | 2795412959       | Luxonis, Inc. OAK4-D R9        | 10.12.102.126, 172.23.136.130          | Luxonis OS RVC4 1.32.1 | 0.20.0        | Setup (unadopted) |
+---+------------------+--------------------------------+----------------------------------------+------------------------+---------------+-------------------+
oakctl device connection set 1 # Connect to the first device
```

This repository contains the UVC C++ example.

```sh
git clone --depth 1 --branch main https://github.com/luxonis/oak-examples
cd oak-examples
git submodule update --init --recursive
```

```sh
cd cpp/uvc
oakctl app build .
```

```sh
oakctl app install *.oakapp -d 2
```

The `-d 2` argument selects the OAK4 device from the list above.

```sh
oakctl app list -d 2
+---+--------+---------------------------------+---------+--------------+
| E | App Id | Identifier                      | Status  | Frontend URL |
+=======================================================================+
| * | d4ed4  | com.example.streaming.uvc:3.0.0 | running |              |
+---+--------+---------------------------------+---------+--------------+
```
