Init Core
chaos.lib.inits
Scripts for initializing various parts of Ch-aOS, including Chobolo configurations and secret management.
checkForSsh()
Checks for SSH public keys in ~/.ssh directory.
Returns:
| Type | Description |
|---|---|
list[Path]
|
list[Path]: A list of paths to public keys found. |
genBatchGpg(name, email)
Generate GPG key in batch mode using provided name and email.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The full name to associate with the key. |
required |
email
|
str
|
The email address to associate with the key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The fingerprint of the newly generated key. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If key generation fails or is cancelled. |
Notes
Uses the best practices for key generation with EdDSA and Curve25519. Deps: gnupg
genGpgManual()
Lists all existing GPG secret keys and prompts user to select one by fingerprint.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: A tuple containing the encryption engine ("pgp") and the chosen fingerprint. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the keys could not be listed. |
ValueError
|
If no secret keys are found or an invalid fingerprint is provided. |
handle_init(payload)
Handles various initialization commands based on the payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
InitPayload
|
The initialization configuration detailing the command and targets. |
required |
Returns:
| Type | Description |
|---|---|
ResultPayload[DictConfig | ListConfig | None]
|
ResultPayload[DictConfig | ListConfig | None]: The result payload of the requested init action. |
initChobolo(keys, targets)
Script to initialize Chobolo configuration based on provided keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
dict
|
A dictionary of plugins. |
required |
targets
|
list
|
A list of target configurations to initialize. |
required |
Returns:
| Type | Description |
|---|---|
ResultPayload[DictConfig | ListConfig | None]
|
ResultPayload[DictConfig | ListConfig | None]: The result payload containing the final configuration. |
Notes
See plugDiscovery.py for more details on the keys format.
initSecrets()
Main Entry point for initializing secrets management with SOPS.
Raises:
| Type | Description |
|---|---|
EnvironmentError
|
If required dependencies (sops, gpg/age) are missing. |
RuntimeError
|
If initialization steps or SOPS encryption fail. |
setupAge()
Setup Age keys for Sops encryption.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: A tuple containing the encryption engine ("age") and the derived public key. |
Raises:
| Type | Description |
|---|---|
EnvironmentError
|
If age-keygen is not installed. |
RuntimeError
|
If key generation or saving fails. |
Notes
Deps: age-keygen
setupGpg()
Setup GPG keys for Sops encryption.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: A tuple containing the encryption engine ("pgp") and the generated or selected fingerprint. |
Raises:
| Type | Description |
|---|---|
EnvironmentError
|
If gpg is not installed. |
RuntimeError
|
If the operation is cancelled by the user. |
setupSsh()
Setup SSH key for Sops encryption.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: A tuple containing the encryption engine ("age") and the public key content. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a selected key file is empty. |
setupSshToAge()
Setup age keys using ssh-to-age conversion.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: A tuple containing the encryption engine ("age") and the derived public key. |
Raises:
| Type | Description |
|---|---|
EnvironmentError
|
If ssh-to-age is not installed. |
FileNotFoundError
|
If no SSH public keys are found. |
RuntimeError
|
If there's an error converting keys or saving to disk. |
Notes
Deps: ssh-to-age