From 9a4495583a91b76dc13bd35e07e31407ec2a8657 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 7 Oct 2025 04:56:32 +0200 Subject: [PATCH] fix: Retrieve gateway IP --- src/check.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/check.sh b/src/check.sh index de23293..d7842ff 100644 --- a/src/check.sh +++ b/src/check.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -Eeuo pipefail +: "${DHCP:="N"}" : "${NETWORK:="Y"}" [ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1 @@ -9,6 +10,7 @@ set -Eeuo pipefail 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 @@ -16,13 +18,13 @@ location=$(<"$file") if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then - if [[ "$location" == "20.20"* ]]; then - ip="20.20.20.1" + if [[ "$DHCP" == [Yy1]* ]]; then + ip=$(<"$address") + echo "Failed to reach DSM at http://$location" + else + ip=$(<"$gateway") port="${location##*:}" echo "Failed to reach DSM at port $port" - else - echo "Failed to reach DSM at http://$location" - ip=$(<"$address") fi echo "You might need to whitelist IP $ip in the DSM firewall." && exit 1