From: Harvie Date: Fri, 20 Aug 2010 06:36:34 +0000 (+0200) Subject: Added automagic tool to acces virtualbox machines with serial console using minicom X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=3f763f5aec10dca479fa371cd77ef5a4d40a8337;p=mirrors%2FPrograms.git Added automagic tool to acces virtualbox machines with serial console using minicom --- 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";