core-agent-linux/misc/qvm-console

39 lines
875 B
Plaintext
Raw Normal View History

2019-04-30 11:42:38 +02:00
#!/bin/bash
print_usage() {
cat >&2 <<USAGE
Usage: $0 vmname
2019-05-07 14:09:46 +02:00
Connects to another VM console using the admin.vm.Console RPC service.
USAGE
}
if [ $# -lt 1 ] ; then
print_usage
exit 1
fi
2019-04-30 11:42:38 +02:00
QREXEC_REQUESTED_TARGET="$1"
qrexec_console() {
QREXEC_REQUESTED_TARGET="$1"
2019-05-07 14:09:46 +02:00
qrexec-client-vm "$QREXEC_REQUESTED_TARGET" admin.vm.Console
2019-04-30 11:42:38 +02:00
2019-05-07 14:09:46 +02:00
# exit code 200 is flock exit code in admin.vm.Console
2019-04-30 11:42:38 +02:00
exit_code=$?
if [ $exit_code -gt 0 ]; then
if [ $exit_code -ne 200 ]; then
printf "Cannot connect to %s" "$QREXEC_REQUESTED_TARGET"
else
printf "A qube is already connected to %s" "$QREXEC_REQUESTED_TARGET"
fi
exit 1
fi
}
export -f qrexec_console
printf "Use '^]' to exit remote console\n"
socat file:/dev/tty,rawer,escape=0x1d SYSTEM:"qrexec_console $QREXEC_REQUESTED_TARGET" 2>/dev/null
2019-04-30 11:42:38 +02:00
printf '\n'