Skip to content

Commit

Permalink
fix: Detect device
Browse files Browse the repository at this point in the history
* fix: Detect device
  • Loading branch information
kroese authored Dec 28, 2023
1 parent 08e4084 commit 159fce6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
19 changes: 16 additions & 3 deletions src/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,23 @@ if [[ "$CONSOLE" == [Yy]* ]]; then
fi

[[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && set -x
qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS}

dev=$(qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS})
{ set +x; } 2>/dev/null
cat /dev/pts/1 2>/dev/null & wait $! || true

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

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

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

cat "$dev" 2>/dev/null & wait $! || true

sleep 1
finish 0
10 changes: 7 additions & 3 deletions src/power.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ _graceful_shutdown() {
local code=$?
local pid cnt response

[ -f "$QEMU_COUNT" ] && return
echo 0 > "$QEMU_COUNT"

set +e

if [ -f "$QEMU_COUNT" ]; then
echo && info "Ignored $1 signal, already shutting down..."
return
fi

echo 0 > "$QEMU_COUNT"
echo && info "Received $1 signal, sending shutdown command..."

if [ ! -f "$QEMU_PID" ]; then
Expand Down

0 comments on commit 159fce6

Please sign in to comment.