From f42eb41a5164780ac8bf5934d0fa6278a6ace6f0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 3 Sep 2020 11:44:20 +0200 Subject: Initial support for private brep instance setup --- etc/private/vm-login | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 etc/private/vm-login (limited to 'etc/private/vm-login') diff --git a/etc/private/vm-login b/etc/private/vm-login new file mode 100755 index 0000000..3b501ca --- /dev/null +++ b/etc/private/vm-login @@ -0,0 +1,30 @@ +#! /usr/bin/env bash + +# Get virtual machine console. +# +usage="usage: $0 " + +owd="$(pwd)" +trap "{ cd '$owd'; exit 1; }" ERR +set -o errtrace # Trap in functions. + +function info () { echo "$*" 1>&2; } +function error () { info "$*"; exit 1; } + +con="$1" + +if [ -z "$con" ]; then + error "missing console socket" +fi + +pty="$(dirname "$con")/$(basename -s .sock "$con").pty" + +socat "UNIX-CONNECT:$con" "PTY,link=$pty" & +pid="$!" + +screen "$pty" + +# Note: socat may have already terminated (e.g., VM was shut down). +# +kill "$pid" 2>/dev/null || true +wait -- cgit v1.1