diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-09-04 22:26:09 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-09-04 22:26:09 +0200 |
| commit | 8165883a153e4bc2d50fa3710e47b76d9f79bb15 (patch) | |
| tree | 459dfc254dea60427159d24f48af4899b1d9fa53 /src/engine_container.c | |
| parent | 8c8d3ed3d7a478789a8fe3edf15ca4ce4c6a8b66 (diff) | |
Started Implementing Container Creation
We setup a single-use SSH key and can generate an SSH
configuration. Additionally, we support user SSH settings in
`~/.config/dbx/$NAME.ssh_config`.
This still doesn't quite work (there are some left-over TODOs).
In particular:
1. We need to get the generated SSH public key to the authorized
keys list on the devbox
2. We need to SCP and run the optional post-installation script
Diffstat (limited to 'src/engine_container.c')
| -rw-r--r-- | src/engine_container.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/engine_container.c b/src/engine_container.c new file mode 100644 index 0000000..6ddf122 --- /dev/null +++ b/src/engine_container.c @@ -0,0 +1,49 @@ +#include <errno.h> +#include <stdlib.h> + +#include "dbx.h" + +struct dbx_engine { + char container[PATH_MAX]; +}; + +struct dbx_engine *dbx_engine_init(void) { + struct dbx_engine *engine = calloc(1, sizeof(struct dbx_engine)); + if (engine == NULL) { + dbx_perror("calloc", errno); + return NULL; + } + + if (!dbx_proc_find("container", engine->container)) { + goto error; + } + + const char *const status[] = {engine->container, "system", "status", NULL}; + if (dbx_proc_run(status, DBXP_NONE) != 0) { + dbx_printerr("container engine must started with `container system start`"); + goto error; + } + + return engine; + +error: + free(engine); + return NULL; +} + +bool dbx_engine_create(struct dbx_engine *engine, const char *image, + const char *name, uint16_t sshd_port) { + const char *const create[] = { + engine->container, "machine", "create", "--name", name, + "--no-boot", "--home-mount=none", image, NULL}; + if (dbx_proc_run(create, DBXP_ALL) != 0) { + return false; + } + + // TODO(nlordell): Set the SSHD port + // TODO(nlordell): Copy over the SSH key. + + return true; +} + +void dbx_engine_destroy(struct dbx_engine *engine) { free(engine); } |
