summary refs log tree commit diff
path: root/host/rootfs/usr/bin/vm-console
blob: 00d823c1516c569f637299bd768d64fc5b3e8dec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/execlineb -S1
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>

backtick -E pty {
  pipeline -w { jq -r .config.console.file }
  ch-remote --api-socket /run/service/ext-vm-${1}/env/cloud-hypervisor.sock info
}

foreground {
  flock -n $pty
  foot -T $1 --pty $pty
}
importas -iu ? ?
foreground {
  if { test $? != 230 }
  fdmove -c 1 2
  printf "%s: a console for %s is already open\n" $0 $1
}
exit $?