Relay Shell
relay_shell · Nodes · Iot
Runs a shell command, or starts a program with its arguments, on a Verdalia Relay inside a mount.
Relay Shell#
Run a command on a Verdalia Relay, in a directory inside one of its mounts: a command line for the Relay user's shell, or a program and its arguments started without a shell.
The shell plugin is off on every Relay until its owner runs verdalia-relay config enable shell,
and it needs at least one filesystem mount. Until then the node fails with the Relay's own
message saying so. Either form gets no stdin and the Relay's environment with two changes: PATH
is the one declared in ~/.config/environment.d on that computer (the Relay's own PATH when no
file there declares one), evaluated for each run, and while someone is logged in to that
computer's desktop, the desktop's display variables (WAYLAND_DISPLAY, DISPLAY, XAUTHORITY,
XDG_SESSION_TYPE, XDG_CURRENT_DESKTOP); with nobody logged in, none of them.
Shell and Program#
Shell runs one command line under the Relay user's default shell: $SHELL -c <command>,
falling back to /bin/sh when $SHELL is unset or not an absolute path (%COMSPEC% /C <command>
on Windows). It is not a login shell, so profile files are not read. Interpolated values are
inserted as-is, not escaped, so the shell reads quotes, $, *, ; and history modifiers such as
zsh's :r inside them. Use it for a fixed command line.
Program starts a program directly with a list of arguments: the first is the program, the rest
its arguments. Each argument reaches the program exactly as written, with no splitting, globbing,
quoting, $ expansion, aliases or operators. Anything built from data belongs here. A bare name
(git) is looked up on that PATH at the time of the run, a relative path with a separator
(./scripts/check) is taken from the run directory, and an absolute path is used as is. On
Windows each PATH directory is tried for the bare name first, then with each extension in
PATHEXT in order (.COM;.EXE;.BAT;.CMD when it is unset). A .bat or .cmd file runs through
cmd.exe, which refuses an argument it cannot pass on safely; the node then fails as a program
that could not be started.
A script that needs pipes, && or loops runs the shell as the program and passes the values as its
positional parameters, never inside the script text:
{
"kind": "program",
"argv": {
"source": "configured",
"argv": [
{"content": "sh"},
{"content": "-c"},
{"content": "git fetch -q origin \"+refs/heads/$1:refs/remotes/origin/$1\""},
{"content": "sh"},
{"content": "{{ input.branch }}"}
]
}
}
Configuration#
connection — Verdalia Relay connection: pick one, or write a template such as
{{ input.connection_id }} that resolves to a connection id from input on each run, so one node
serves several relays. The node fails, naming the template and what it resolved to, when the input
has no value for it, the value is not a connection id, no Verdalia Relay connection has that id, or
that relay is offline.
mount — Mounted filesystem name configured in the Relay. A read-only mount refuses every command, since a shell cannot be kept read-only.
path — Directory inside the mount to run in. Empty runs in the mount root.
invocation — What runs, as one of:
{"kind": "shell", "command": …}: the command line. Supports interpolation frominput.{"kind": "program", "argv": {"source": "configured", "argv": [ … ]}}: one row per argument, the program first. Each row supports interpolation frominputand becomes exactly one argument as rendered, spaces, quotes,$and:included; rows are never split or trimmed.{"kind": "program", "argv": {"source": "input", "argv": {"content": "{{ input.argv }}"}}}: one reference that must resolve to a non-empty array of strings. Anything else fails the node naming what it got, such asargv must resolve to a non-empty array of strings, not an objectorargv[2] is a number, not a string.
A new node is a Shell with an empty command. A draft with an empty command, blank rows or a blank reference saves; validation reports it and the node refuses to run it.
With input {"b": "feat/x"}, this invocation passes git exactly
+refs/heads/feat/x:refs/remotes/origin/feat/x, whatever the Relay user's shell is:
{
"kind": "program",
"argv": {
"source": "configured",
"argv": [
{"content": "git"},
{"content": "fetch"},
{"content": "origin"},
{"content": "+refs/heads/{{ input.b }}:refs/remotes/origin/{{ input.b }}"}
]
}
}
timeout_seconds — Seconds before the command and everything it started are killed, 1 to 50. Default 30.
fail_on_error — Fail the node when the command exits non-zero, is killed, or times out. The
failure message carries the exit status and the end of stderr. Default true. Turn it off to
branch on success or exit_code instead.
The Relay keeps at most 1 MiB of each output stream and sets the matching *_truncated flag
past that. When the command ends, anything it left running in the background is stopped.
Inputs#
input — JSON value used as interpolation context.
Output#
output
{
"mount": "work",
"path": "src",
"shell": "/bin/zsh",
"success": false,
"exit_code": 3,
"signal": null,
"timed_out": false,
"stdout": "…",
"stderr": "…",
"stdout_truncated": false,
"stderr_truncated": false,
"duration_ms": 12
}
success is true only when the command exited with status 0. shell names the shell a Shell
invocation ran under and is null for a Program. A Relay refusal always fails the node, whatever
fail_on_error says: unknown mount, missing or non-directory path, read-only mount, plugin off,
and for a Program an empty argument list, an empty program name, an argument holding a NUL
character, or a program that cannot be started:
program 'gti' was not found on your PATH (environment.d) for a bare name, where the parentheses
name the PATH searched (Relay's PATH: no PATH in ~/.config/environment.d when no file there
declares one), and program './scripts/check' could not be started: <reason> for a path that is
missing or not executable. The program is named in these messages cut to its first 160
characters. A Relay too old to start a program without a shell fails a Program
with This Relay's version cannot start a program without a shell; update the Relay.
Inputs
inputRequired
Outputs
output
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
connection | connection(verdalia_relay) | Yes | Verdalia Relay connection to use, or a template that resolves to a connection id from the node's input, such as {{ input.connection_id }} |
mount | string | Yes | Mounted filesystem name configured in the Relay |
path | string | No | Directory inside the mount to run in; empty for the mount root |
invocation | tagged_union | No | A command line for the Relay user's shell, or a program and its arguments started directly without a shell |
timeout_seconds | integer | No | Seconds before the command or program is killed, 1 to 50 |
fail_on_error | boolean | No | Fail the node when the command or program exits non-zero or times out |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |