# Run it with the Linux kit

The kit installs the agent as a systemd service, after checking every file and showing the partner agreement. Calls go to https://supply.coronium.ai. The kit carries these same steps in its `README.md`.

<!-- facts:begin part.linux-kit -->
## Needs

- Linux on x86-64 or ARM64, root through `sudo`, and `curl` and `sha256sum`.
- The system's certificate roots, which minimal and container images leave out: `sudo apt-get install -y ca-certificates` on Debian and Ubuntu, `sudo apk add ca-certificates` on Alpine, `sudo dnf install -y ca-certificates` on Fedora and RHEL.
- Outbound TCP to the relay. No inbound port.
- From the device's enrolment at https://supply.coronium.ai/farmer or through the API: the relay `host:port`, the device id, the device secret, and the agreement digest shown for the device, which is the `sha256` of the text the account signed.
- The kit digest: the line for `coronium-agent-linux-<arch>/SHA256SUMS` in https://supply.coronium.ai/kit/SHA256SUMS, which the farmer portal also shows.
- A person at the device's terminal: the installer shows the partner agreement and asks them to type it. An agent hands this step to its person, or runs the program alone instead.

## Steps

1. Download and check the kit as your normal user, in a folder of its own, before anything runs as root. `ARCH` is `amd64` when `uname -m` prints `x86_64`, and `arm64` for `aarch64`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
ARCH=amd64
curl -fsSLO "$SUPPLY/kit/SHA256SUMS"
curl -fsSLO "$SUPPLY/kit/coronium-agent-linux-$ARCH.tar.gz"
grep " coronium-agent-linux-$ARCH.tar.gz\$" SHA256SUMS | sha256sum -c
tar -xzf "coronium-agent-linux-$ARCH.tar.gz"
grep " coronium-agent-linux-$ARCH/SHA256SUMS\$" SHA256SUMS | sha256sum -c
cd "coronium-agent-linux-$ARCH" && sha256sum -c SHA256SUMS
```

Expect: every line ends `OK`. If one does not, stop and write to the contact in `PARTNER-AGREEMENT.md`. Nothing is signed yet: the digests are only as trustworthy as the site they came from. Safe to repeat: yes.

2. Install, in the kit's folder. Without systemd, add `--no-systemd`: the installer then prints one command that runs the agent in the foreground as the user `nobody`, and nothing starts it after a reboot.

```sh
umask 077
sudo ./install.sh
```

Expect: `Installed.` and the consent record, which holds no secret. The settings go to `/etc/coronium-agent/agent.env`, readable by root only. If refused: `no_certificate_roots` (install the roots above), `kit_digest_mismatch` (download the kit again), `agreement_not_accepted` (the kit's agreement is not the text the account signed: sign the text in force, then enrol), `consent_not_given`, `bad_relay`, `bad_device_id` or `bad_secret` (run it again with the right value), `no_systemd` (add `--no-systemd`), `wrong_architecture`, `checksum_mismatch` or `consent_draft` (get a new kit). Safe to repeat: yes, and it keeps the settings.

3. Check.

```sh
umask 077
systemctl is-active coronium-agent
journalctl -u coronium-agent -n 20 --no-pager
```

Expect: `active` and `connected to the relay`. A problem is one log line with its cause and its fix, and the agent dials again by itself. If its settings are refused five times in five minutes the service stops: fix the cause, then `sudo systemctl restart coronium-agent`.

## Stop and remove

`sudo systemctl disable --now coronium-agent` stops it and keeps it stopped after a reboot; `sudo systemctl enable --now coronium-agent` starts it again. To remove the service, the program, its user and `/etc/coronium-agent` with the secret, run this in the kit's folder:

```sh
umask 077
sudo ./uninstall.sh
```

It warns, with the process id, about an agent you started yourself, which it does not stop. Removing the agent does not withdraw the device: withdrawing is a request to Coronium, at the contact in section 10 of `PARTNER-AGREEMENT.md`.
<!-- facts:end part.linux-kit -->
