From 6478fa4412dfb55236235caad06669dec910c83d Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 17 Apr 2023 04:12:57 +0200 Subject: [PATCH 1/5] Show curl errors --- run/power.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/power.sh b/run/power.sh index 8473fc0..df707d3 100644 --- a/run/power.sh +++ b/run/power.sh @@ -42,7 +42,7 @@ _graceful_shutdown(){ # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null # Send shutdown command to guest agent tools instead via serial port - RESPONSE=$(curl -s -m 2 -S http://127.0.0.1:2210/write?command=6 2>&1) + RESPONSE=$(curl -s -m 3 -S http://127.0.0.1:2210/write?command=6) if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then From d650e8d46f78d6f1ae69a0412592d3d051922a03 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 17 Apr 2023 04:16:48 +0200 Subject: [PATCH 2/5] Package installation --- agent/agent.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/agent.sh b/agent/agent.sh index 556571c..074d8e0 100644 --- a/agent/agent.sh +++ b/agent/agent.sh @@ -28,7 +28,7 @@ function checkNMI { finish() { - echo "Shutting down agent.." > /dev/ttyS0 + echo "Shutting down vDSM Guest Agent.." > /dev/ttyS0 exit } @@ -54,12 +54,12 @@ if [ "$first_run" = true ]; then for filename in /usr/local/packages/*.spk; do if [ -f "$filename" ]; then - /usr/syno/bin/synopkg install "$filename" > /dev/null + /usr/syno/bin/synopkg install "$filename" > /dev/ttyS0 BASE=$(basename "$filename" .spk) BASE="${BASE%%-*}" - /usr/syno/bin/synopkg start "$BASE" > /dev/null + /usr/syno/bin/synopkg start "$BASE" > /dev/ttyS0 rm "$filename" From 2e0449aacffd9a0e86f2659830a77dc8132c797d Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 17 Apr 2023 04:43:24 +0200 Subject: [PATCH 3/5] Revert to sleep --- agent/agent.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/agent/agent.sh b/agent/agent.sh index 074d8e0..52993ef 100644 --- a/agent/agent.sh +++ b/agent/agent.sh @@ -3,13 +3,6 @@ set -u # Functions -snore() -{ - local IFS - [[ -n "${_snore_fd:-}" ]] || exec {_snore_fd}<> <(:) - read ${1:+-t "$1"} -u $_snore_fd || : -} - function checkNMI { local nmi @@ -28,7 +21,7 @@ function checkNMI { finish() { - echo "Shutting down vDSM Guest Agent.." > /dev/ttyS0 + echo "Shutting down Guest Agent.." > /dev/ttyS0 exit } @@ -77,11 +70,13 @@ echo "-------------------------------------------" > /dev/ttyS0 echo " You can now login to DSM at port 5000 " > /dev/ttyS0 echo "-------------------------------------------" > /dev/ttyS0 +# TODO: Auto-update agent + # Wait for NMI interrupt as a shutdown signal while true; do checkNMI - snore 2 + sleep 2 done From bcfc58a870d8d46c206609301575f9dd9e500941 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 17 Apr 2023 04:46:07 +0200 Subject: [PATCH 4/5] Remove snore --- run/power.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/run/power.sh b/run/power.sh index df707d3..66c5ed6 100644 --- a/run/power.sh +++ b/run/power.sh @@ -19,13 +19,6 @@ _trap(){ done } -snore() -{ - local IFS - [[ -n "${_snore_fd:-}" ]] || exec {_snore_fd}<> <(:) - read ${1:+-t "$1"} -u $_snore_fd || : -} - _graceful_shutdown(){ local QEMU_MONPORT="${QEMU_MONPORT:-7100}" @@ -42,7 +35,7 @@ _graceful_shutdown(){ # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null # Send shutdown command to guest agent tools instead via serial port - RESPONSE=$(curl -s -m 3 -S http://127.0.0.1:2210/write?command=6) + RESPONSE=$(curl -s -m 2 -S http://127.0.0.1:2210/write?command=6) if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then From 3b3b6f107d438e66fd76e92e7da17c03534174bb Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 17 Apr 2023 04:46:33 +0200 Subject: [PATCH 5/5] Sleep --- run/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/run.sh b/run/run.sh index af76aab..72194c1 100755 --- a/run/run.sh +++ b/run/run.sh @@ -54,5 +54,5 @@ set +m # Since we started the QEMU process with -m, we need to poll if it's still running while [ -d "/proc/$(cat ${_QEMU_PID})" ]; do - snore 1 + sleep 1 done