cdba: Add option to run cdba-server locally without ssh

cdba is mainly intended for remote usage, but it also works well for
controlling devices that you just need occasionally and then directly
connect to your local laptop instead of a remote server.

Another use case is if you just use cdba to power up a standard distro on a
remote board and then SSH into it remotely. To avoid interruptions, it's
better to start cdba locally on the server in a tmux session. That way,
temporary disconnections do not power down the board.

From a protocol perspective, everything is transferred through STDIN and
STDOUT. It makes no difference if we have ssh piping the data to a remote
server, or if the data is directly passed to the cdba-server binary started
locally. The functionality works exactly the same.

Add an option for this in the cdba client. If the -h <host> option is
omitted, cdba-server is started locally.
This commit is contained in:
Stephan Gerhold
2025-01-10 14:34:00 +01:00
parent 828d76df63
commit 06531f3db1
2 changed files with 13 additions and 10 deletions

5
README
View File

@@ -19,11 +19,12 @@ from sandbox/cdba/cdba-server. Available devices are read from $HOME/.cdba
= Client side
The client is invoked as:
cdba -b <board> -h <host> [-c <power-cylce-count>] [-s <status-fifo>] [boot.img]
cdba -b <board> [-h <host>] [-c <power-cylce-count>] [-s <status-fifo>] [boot.img]
<host> will be connected to using ssh and <board> will be selected for
operation. As the board's fastboot interface shows up the given boot.img
will be transfered and booted on the device. If [boot.img] is omitted,
will be transfered and booted on the device. If <host> is omitted, the
cdba-server is started locally without using ssh. If [boot.img] is omitted,
"fastboot continue" is run to boot the installed operating system.
The board will execute until the key sequence ^A q is invoked or the board

18
cdba.c
View File

@@ -103,8 +103,13 @@ static int fork_ssh(const char *host, const char *cmd, int *pipes)
close(piped_stderr[0]);
close(piped_stderr[1]);
execlp("ssh", "ssh", host, cmd, NULL);
err(1, "launching ssh failed");
if (host) {
execlp("ssh", "ssh", host, cmd, NULL);
err(1, "launching ssh failed");
} else {
execlp(cmd, cmd, NULL);
err(1, "launching cdba-server failed");
}
default:
close(piped_stdin[0]);
close(piped_stdout[1]);
@@ -583,12 +588,12 @@ static void usage(void)
{
extern const char *__progname;
fprintf(stderr, "usage: %s -b <board> -h <host> [-t <timeout>] "
fprintf(stderr, "usage: %s -b <board> [-h <host>] [-t <timeout>] "
"[-T <inactivity-timeout>] [boot.img]\n",
__progname);
fprintf(stderr, "usage: %s -i -b <board> -h <host>\n",
fprintf(stderr, "usage: %s -i -b <board> [-h <host>]\n",
__progname);
fprintf(stderr, "usage: %s -l -h <host>\n",
fprintf(stderr, "usage: %s -l [-h <host>]\n",
__progname);
exit(1);
}
@@ -667,9 +672,6 @@ int main(int argc, char **argv)
}
}
if (!host)
usage();
switch (verb) {
case CDBA_BOOT:
if (optind > argc || !board)