openrc
OpenrcConfigFile
¶
The current content of an OpenRC configuration file, or None when absent.
Commands:
test -e <path> && { printf '#reemote-openrcconfig\n'; cat -- <path>; }
Returns:
str | None
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_config.py.
OpenrcEnabled
¶
Whether each OpenRC service is enabled in a runlevel.
Commands:
rc-update show -v
Returns:
dict[str, bool]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_openrc_enabled.py.
OpenrcRunlevels
¶
The runlevels and the service names assigned to each.
Commands:
ls -R /etc/runlevels 2>/dev/null || true
Returns:
dict[str, list[str]]
Raises:
HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_openrc_runlevels.py.
OpenrcServices
¶
The raw state word of each OpenRC service in a runlevel.
Commands:
rc-status <runlevel>
Returns:
dict[str, str]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_openrc_services.py.
OpenrcStatus
¶
Whether each OpenRC service in a runlevel is running.
Commands:
rc-status <runlevel>
Returns:
dict[str, bool]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_openrc_status.py.
OpenrcVersion
¶
The installed OpenRC version, or None without OpenRC.
Commands:
openrc --version 2>/dev/null || true
Returns:
str | None
Raises:
HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_openrc_version.py.
config
async
¶
config(
ctx: OpContext,
key: str,
value: str,
service: str | None = None,
present: bool = True,
**kwargs: Any,
) -> AsyncGenerator[Command]
Set or unset a variable in /etc/rc.conf or a service's /etc/conf.d file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
key
|
str
|
Name of the shell variable to manage -- a shell
identifier such as |
required |
value
|
str
|
The value to assign, rendered as |
required |
service
|
str | None
|
The service whose
|
None
|
present
|
bool
|
Whether the variable should be set
( |
True
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated openrc config spool-and-install commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/openrc/openrc_config.py.
custom_runlevel
async
¶
custom_runlevel(
ctx: OpContext,
runlevel: str,
present: bool = True,
stacked_to: str | None = None,
**kwargs: Any,
) -> AsyncGenerator[Command]
Create or remove a custom OpenRC runlevel, optionally stacked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
runlevel
|
str
|
Name of the custom runlevel to create or remove
(a directory under |
required |
present
|
bool
|
Whether the runlevel should exist
( |
True
|
stacked_to
|
str | None
|
An existing runlevel to stack
this one onto ( |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated runlevel-directory and rc-update commands. |
Raises:
HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/openrc/openrc_custom_runlevel.py.
runlevel
async
¶
runlevel(
ctx: OpContext,
service: str,
runlevel: str = "default",
enabled: bool = True,
**kwargs: Any,
) -> AsyncGenerator[Command]
Add or remove a service from an OpenRC runlevel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
service
|
str
|
Name of the service (its |
required |
runlevel
|
str
|
The runlevel to manage the assignment in. Defaults to "default". |
'default'
|
enabled
|
bool
|
Whether the service should be assigned
to the runlevel ( |
True
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated rc-update commands. |
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_runlevel.py.
service
async
¶
service(
ctx: OpContext,
service: str,
running: bool | None = True,
restarted: bool = False,
reloaded: bool = False,
enabled: bool | None = None,
runlevel: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Manage the state of an OpenRC service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
service
|
str
|
Name of the service to manage (its |
required |
running
|
bool | None
|
Whether the service should be
running ( |
True
|
restarted
|
bool
|
Whether to restart the service (only if it is already running). Defaults to False. |
False
|
reloaded
|
bool
|
Whether to reload the service (only if it is already running). Defaults to False. |
False
|
enabled
|
bool | None
|
Whether the service should be
enabled in |
None
|
runlevel
|
str
|
The runlevel the status and boot settings are managed for. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated rc-service and rc-update commands. |
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/openrc/openrc_service.py.