Compare commits

..

4 Commits
v5.09 ... v5.10

Author SHA1 Message Date
Kroese
19aa313753 fix: Shellcheck (#509) 2023-12-28 08:35:51 +01:00
Kroese
9db12cd25f fix: Device detection
* fix: Device detection
2023-12-28 08:31:32 +01:00
Kroese
69e785e6ee fix: Shutdown message
* fix: Shutdown message
2023-12-28 05:26:53 +01:00
Kroese
159fce6839 fix: Detect device
* fix: Detect device
2023-12-28 05:04:40 +01:00
2 changed files with 33 additions and 9 deletions

View File

@@ -24,10 +24,30 @@ if [[ "$CONSOLE" == [Yy]* ]]; then
fi
[[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && set -x
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
cat /dev/pts/1 2>/dev/null & wait $! || true
if [[ "$msg" != "char"* || "$msg" != *"serial0)" ]]; then
echo "$msg"
fi
dev="${msg#*/dev/p}"
dev="/dev/p${dev%% *}"
if [ ! -c "$dev" ]; then
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
cat "$dev" 2>/dev/null & wait $! || true
sleep 1
finish 0

View File

@@ -35,7 +35,7 @@ finish() {
if [ -f "$QEMU_PID" ]; then
pid="$(cat "$QEMU_PID")"
echo && error "Forcefully quitting QEMU process, reason: $reason..."
echo && error "Forcefully terminating QEMU process, reason: $reason..."
{ kill -15 "$pid" || true; } 2>/dev/null
while isAlive "$pid"; do
@@ -51,7 +51,7 @@ finish() {
closeNetwork
sleep 1
echo && info "Shutdown completed!"
echo && echo " Shutdown completed!"
exit "$reason"
}
@@ -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
@@ -94,7 +98,7 @@ _graceful_shutdown() {
response="${response#*message\"\: \"}"
[ -z "$response" ] && response="second signal"
echo && error "Forcefully quitting because of: ${response%%\"*}"
echo && error "Forcefully terminating because of: ${response%%\"*}"
{ kill -15 "$pid" || true; } 2>/dev/null
fi