Unverified Commit 9db12cd2 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Device detection

* fix: Device detection
parent 69e785e6
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -24,19 +24,26 @@ if [[ "$CONSOLE" == [Yy]* ]]; then
fi

[[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && set -x
dev=$(qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS})
msg=$(qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS})
{ set +x; } 2>/dev/null

if [[ "$dev" != "char"* || "$dev" != *"redirected to"* ||  "$dev" != *")" ]]; then
  error "$dev"
  finish 33
if [[ "$msg" != "char"* ||  "$msg" != *"serial0)" ]]; then
  echo "$msg"
fi

dev="${dev#*/dev/}"
dev="/dev/${dev%% *}"
dev="${msg#*/dev/p}"
dev="/dev/p${dev%% *}"

if [ ! -c "$dev" ]; then
  error "Device $dev not found!"
  dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000')
  dev="${dev#*charserial0}"
  dev="${dev#*pty:}"
  dev="${dev%%$'\n'*}"
  dev="${dev%%$'\r'*}"
fi

if [ ! -c "$dev" ]; then
  error "Device `$dev` not found!"
  finish 34
fi