virtual-dsm/src/check.sh

31 lines
719 B
Bash
Raw Normal View History

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
[ -f "/run/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
[ ! -f "/run/qemu.pid" ] && echo "QEMU is not running yet.." && exit 0
2023-12-15 09:01:19 +01:00
file="/run/dsm.url"
address="/run/qemu.ip"
2023-12-15 09:01:19 +01:00
[ ! -f "$file" ] && echo "DSM has not enabled networking yet.." && exit 1
location=$(cat "$file")
2023-05-08 19:43:31 +02: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"
ip="$(cat "$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
echo "Healthcheck OK"
2023-04-21 08:04:53 +02:00
exit 0