feat: Improve shutdown (#448)

* feat: Improve shutdown
This commit is contained in:
Kroese
2023-12-10 09:22:35 +01:00
committed by GitHub
parent 03d2665725
commit b9f3e52ba4
6 changed files with 19 additions and 10 deletions

View File

@@ -5,16 +5,18 @@ info () { printf "%b%s%b" "\E[1;34m \E[1;36m" "$1" "\E[0m\n" >&2; }
error () { printf "%b%s%b" "\E[1;31m " "ERROR: $1" "\E[0m\n" >&2; }
file="/run/dsm.url"
url="http://127.0.0.1:2210/read?command=10"
while [ ! -f "$file" ]
do
sleep 3
[ -f "$file" ] && continue
# Healthcheck may have intervened
[ -f "$file" ] && break
# Retrieve IP from guest VM
{ json=$(curl -m 30 -sk http://127.0.0.1:2210/read?command=10); rc=$?; } || :
{ json=$(curl -m 20 -sk "$url"); rc=$?; } || :
(( rc != 0 )) && error "Failed to connect to guest: curl error $rc" && continue
{ result=$(echo "$json" | jq -r '.status'); rc=$?; } || :