2023-04-21 08:04:53 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-12-09 21:45:31 +01:00
|
|
|
set -Eeuo pipefail
|
2023-04-21 08:04:53 +02:00
|
|
|
|
2024-03-12 01:50:43 +01:00
|
|
|
: "${NETWORK:="Y"}"
|
|
|
|
|
2024-01-13 20:25:57 +01:00
|
|
|
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
|
|
|
|
[ ! -f "/run/shm/qemu.pid" ] && echo "QEMU is not running yet.." && exit 0
|
2024-03-12 01:50:43 +01:00
|
|
|
[[ "$NETWORK" != [Yy1]* ]] && echo "Networking is disabled.." && exit 0
|
2023-11-15 19:58:51 +01:00
|
|
|
|
2024-01-13 20:25:57 +01:00
|
|
|
file="/run/shm/dsm.url"
|
|
|
|
address="/run/shm/qemu.ip"
|
2023-12-28 20:25:04 +01:00
|
|
|
|
2023-12-15 09:01:19 +01:00
|
|
|
[ ! -f "$file" ] && echo "DSM has not enabled networking yet.." && exit 1
|
2023-12-10 15:58:37 +01:00
|
|
|
|
2024-01-14 00:00:59 +01:00
|
|
|
location=$(<"$file")
|
2023-05-08 19:43:31 +02:00
|
|
|
|
2023-12-09 21:19:08 +01:00
|
|
|
if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then
|
2023-12-22 04:47:58 +01:00
|
|
|
|
|
|
|
if [[ "$location" == "20.20"* ]]; then
|
|
|
|
ip="20.20.20.1"
|
|
|
|
port="${location##*:}"
|
|
|
|
echo "Failed to reach DSM at port $port"
|
|
|
|
else
|
|
|
|
echo "Failed to reach DSM at http://$location"
|
2024-01-14 00:00:59 +01:00
|
|
|
ip=$(<"$address")
|
2023-12-22 04:47:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "You might need to whitelist IP $ip in the DSM firewall." && exit 1
|
|
|
|
|
2023-04-21 08:19:19 +02:00
|
|
|
fi
|
|
|
|
|
2023-12-07 23:18:47 +01:00
|
|
|
echo "Healthcheck OK"
|
2023-04-21 08:04:53 +02:00
|
|
|
exit 0
|