From 3f763f5aec10dca479fa371cd77ef5a4d40a8337 Mon Sep 17 00:00:00 2001 From: Harvie Date: Fri, 20 Aug 2010 08:36:34 +0200 Subject: [PATCH] Added automagic tool to acces virtualbox machines with serial console using minicom --- bash/virtualbox-shell.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bash/virtualbox-shell.sh diff --git a/bash/virtualbox-shell.sh b/bash/virtualbox-shell.sh new file mode 100755 index 0000000..cc082c0 --- /dev/null +++ b/bash/virtualbox-shell.sh @@ -0,0 +1,26 @@ +#!/bin/bash +dialog=$(which dialog); + +get_vbox_pipes() { + grep 'hostMode="HostPipe"' ~/.VirtualBox/Machines/*/*.xml | sed -e 's/.*path="\([^"]*\)".*/\1/g' | while read i; do + for prefix in '' "$HOME/" "$HOME/.VirtualBox/"; do + socket="$prefix""$i" + test -S "$socket" && { + echo "$socket"; + } + done; + done; +} + +tmp="$(mktemp)"; +get_vbox_pipes | while read socket; do + echo -n "$socket"; echo -ne '\0'; + echo -n "${socket##*/}"; echo -ne '\0'; +done | xargs -0 "$dialog" --no-shadow --trim --title 'Sockets' --backtitle 'VirtualBox serial terminal' --menu -- "Select the socket" 0 0 0 2>"$tmp" || { + echo 'ERROR: No vbox sockets found or selected. :-( Bye.'; + exit 1; +} +socket="$(cat "$tmp")"; +rm -f "$tmp"; + +minicom -c on -o -D unix#"$socket"; -- 2.30.2