Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@
*.xml
.vscode/launch.json
docker-run.sh
setup-ai.sh
.user-context.md
CLAUDE.md
GEMINI.md
58 changes: 58 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# omnect-cli

Command-line tool for developer hosts. It changes omnect OS firmware images
(device identity, certificates, config files, docker images in the image)
and works with devices in the field (SSH tunnel over a bastion host) and
Azure Device Update (create import manifest, import, remove).

## Structure

- `src/cli.rs`: clap definitions of all commands; `src/lib.rs`: `run()`
dispatches them to the handlers.
- `src/auth.rs`, `src/config.rs`: OAuth2 PKCE login against Keycloak with a
local redirect server; the refresh token goes to the system keyring.
- `src/device_update/`: Device Update REST client, token and blob SAS code.
- `src/ssh.rs`: SSH tunnel over the bastion host, key pair creation.
`src/image.rs`: architecture of the firmware image; `src/docker.rs`:
pull and save docker images for it.
- `src/file/`: image operations. `functions.rs` reads a partition out of
the image, changes it with e2tools or mtools and writes back only the
changed blocks. `partition.rs` reads GPT and MBR tables.
- `src/file/sparse.rs`, `bmap.rs`, `output.rs`: keep holes of sparse
images, check and write the bmap, choose the output name and check that
the output image and bmap do not overwrite other files.
- `src/file/signal.rs`: `RegisteredTempDir` is also removed when SIGINT,
SIGTERM or SIGHUP stop the process.
- `src/validators/`: checks for identity config, `du-config.json` and SSH
keys.
- `conf/`: config templates. Its `.gitignore` tracks only `*.template`;
configs made from them are never committed.

## Constraints

- Partition numbers depend on the table type: `factory` and `cert` are 4
and 5 on GPT, 5 and 6 on MBR. The mapping is in `get_partition_info()` in
`src/file/functions.rs`.
- The binary calls external tools: `e2cp`, `e2mkdir`, `mcopy`, `mmd`,
`ssh-keygen` and, on the host only, `docker`. The distroless image in
`Dockerfile` contains only the executables in its explicit copy list. A
new tool goes into the `apt-get install` list and the copy list of
`Dockerfile`, and into `depends` of `[package.metadata.deb]` in
`Cargo.toml`.
- `CONTAINERIZED=true` or `1` (set in the docker image) changes behaviour:
the OAuth redirect server binds `0.0.0.0:4000` instead of
`127.0.0.1:4000` and `[::1]:4000`; `docker inject` and
`ssh set-connection --dir` are refused.
- Errors use `anyhow`; the library target exists only for the binary and
the tests.

## Commands

- Build: `cargo build` (needs `libmagic-dev` on the host)
- Test: `cargo test`. Integration tests need e2tools, mtools and
`ssh-keygen` on the host and use temp dirs under
`/tmp/omnect-cli-integration-tests/`.
- Debian package: `cargo deb` (needs `cargo install cargo-deb`; writes to
`target/debian/`)
- Docker image: `./build-image.sh`. It takes the version from `Cargo.toml`
and installs the `.deb` from `target/debian/`, so run `cargo deb` first.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
name = "omnect-cli"
readme = "README.md"
repository = "https://github.com/omnect/omnect-cli"
version = "0.29.1"
version = "0.29.2"

[dependencies]
actix-web = { version = "4.17", default-features = false, features = ["macros"] }
Expand Down
81 changes: 0 additions & 81 deletions project-context.md

This file was deleted.

Loading