Fix trap handler

This commit is contained in:
Kroese 2023-04-11 05:55:21 +02:00 committed by GitHub
parent 6b50949141
commit 3797b48873

View File

@ -12,7 +12,7 @@ _QEMU_SHUTDOWN_COUNTER=/run/qemu.counter
_trap(){ _trap(){
func="$1" ; shift func="$1" ; shift
for sig ; do for sig ; do
trap '$func $sig' "$sig" trap "$func $sig" "$sig"
done done
} }
@ -22,16 +22,12 @@ _graceful_shutdown(){
local QEMU_POWERDOWN_TIMEOUT="${QEMU_POWERDOWN_TIMEOUT:-120}" local QEMU_POWERDOWN_TIMEOUT="${QEMU_POWERDOWN_TIMEOUT:-120}"
set +e set +e
echo "Trapped $1 signal" echo "Received $1 signal.."
echo 0 > "${_QEMU_SHUTDOWN_COUNTER}" echo 0 > "${_QEMU_SHUTDOWN_COUNTER}"
FILE="${IMG}/agent.ver" FILE="${IMG}/agent.ver"
if [ ! -f "$FILE" ]; then [ ! -f "$FILE" ] && echo "1" > "$FILE"
AGENT_VERSION="1" AGENT_VERSION=$(cat "${FILE}")
echo "$AGENT_VERSION" > "$IMG"/agent.ver
else
AGENT_VERSION=$(cat "${FILE}")
fi
# Don't send the powerdown signal because Synology ignores it # Don't send the powerdown signal because Synology ignores it
# echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null