mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-29 04:07:02 +00:00
39 lines
889 B
Bash
39 lines
889 B
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
cd /run
|
|
. utils.sh # Load functions
|
|
|
|
: "${DHCP:="N"}"
|
|
: "${NETWORK:="Y"}"
|
|
|
|
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down..." && exit 1
|
|
[ ! -s "/run/shm/qemu.pid" ] && echo "QEMU is not running yet..." && exit 0
|
|
disabled "$NETWORK" && echo "Networking is disabled." && exit 0
|
|
|
|
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
|
|
|
|
location=$(<"$file")
|
|
|
|
if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then
|
|
|
|
if enabled "$DHCP"; then
|
|
ip=$(<"$address")
|
|
echo "Failed to reach DSM at http://$location"
|
|
else
|
|
ip=$(<"$gateway")
|
|
port="${location##*:}"
|
|
echo "Failed to reach DSM at port $port"
|
|
fi
|
|
|
|
echo "You might need to whitelist IP $ip in the DSM firewall." && exit 1
|
|
|
|
fi
|
|
|
|
echo "Healthcheck OK"
|
|
exit 0
|