qvm-console-dispvm 735 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. print_usage() {
  3. cat >&2 << USAGE
  4. Usage: $0 vmname
  5. Connects to VM console throught DispVM using the qubes.ShowInTerminal RPC service.
  6. USAGE
  7. }
  8. if [ $# -lt 1 ]; then
  9. print_usage
  10. exit 1
  11. fi
  12. QREXEC_REQUESTED_TARGET="$1"
  13. qvm-check --quiet --running "$QREXEC_REQUESTED_TARGET" > /dev/null 2>&1 || { echo "Error: domain '$QREXEC_REQUESTED_TARGET' does not exist or is not running"; exit 1; }
  14. DISPVM="$(qvm-prefs "$QREXEC_REQUESTED_TARGET" management_dispvm)"
  15. [[ "x$DISPVM" == "x" ]] && { echo "Error: cannot determine management DispVM to use"; exit 1; }
  16. sudo qvm-run -p --localcmd="QREXEC_REQUESTED_TARGET=$QREXEC_REQUESTED_TARGET /etc/qubes-rpc/admin.vm.Console" --service --dispvm="$DISPVM" -- qubes.ShowInTerminal