fix: Provide exitcode on shutdown (#1176)

This commit is contained in:
Kroese
2026-05-31 00:32:49 +02:00
committed by GitHub
parent 476048a4ee
commit 79e85f9fd1
2 changed files with 14 additions and 6 deletions

View File

@@ -4,15 +4,15 @@ set -Eeuo pipefail
: "${DHCP:="N"}"
: "${NETWORK:="Y"}"
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
[ ! -s "/run/shm/qemu.pid" ] && echo "QEMU is not running yet.." && exit 0
[[ "$NETWORK" == [Nn]* ]] && echo "Networking is disabled.." && exit 0
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down..." && exit 1
[ ! -s "/run/shm/qemu.pid" ] && echo "QEMU is not running yet..." && exit 0
[[ "$NETWORK" == [Nn]* ]] && echo "Networking is disabled." && exit 0
file="/run/shm/dsm.url"
address="/run/shm/qemu.ip"
gateway="/run/shm/qemu.gw"
[ ! -s "$file" ] && echo "DSM has not enabled networking yet.." && exit 1
[ ! -s "$file" ] && echo "DSM has not enabled networking yet..." && exit 1
location=$(<"$file")

View File

@@ -108,16 +108,24 @@ terminal() {
_graceful_shutdown() {
local code=$?
local sig="$1"
local code=0
local pid url response
set +e
case "$sig" in
SIGTERM) code=143 ;;
SIGINT) code=130 ;;
SIGHUP) code=129 ;;
SIGABRT) code=134 ;;
SIGQUIT) code=131 ;;
esac
if [ -f "$QEMU_END" ]; then
echo && info "Received $1 signal while already shutting down..."
return
fi
set +e
touch "$QEMU_END"
echo && info "Received $1 signal, sending shutdown command..."