mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-08 02:53:45 +08:00
feat: Improve shutdown
* feat: Improve shutdown
This commit is contained in:
12
src/print.sh
12
src/print.sh
@@ -5,18 +5,26 @@ 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"
|
||||
shutdown="/run/qemu.count"
|
||||
url="http://127.0.0.1:2210/read?command=10"
|
||||
|
||||
|
||||
while [ ! -f "$file" ]
|
||||
do
|
||||
|
||||
# Check if not shutting down
|
||||
[ -f "$shutdown" ] && exit 1
|
||||
|
||||
sleep 3
|
||||
|
||||
[ -f "$shutdown" ] && exit 1
|
||||
|
||||
# Healthcheck may have intervened
|
||||
[ -f "$file" ] && break
|
||||
|
||||
# Retrieve IP from guest VM
|
||||
{ json=$(curl -m 20 -sk "$url"); rc=$?; } || :
|
||||
|
||||
[ -f "$shutdown" ] && exit 1
|
||||
(( rc != 0 )) && error "Failed to connect to guest: curl error $rc" && continue
|
||||
|
||||
{ result=$(echo "$json" | jq -r '.status'); rc=$?; } || :
|
||||
@@ -42,6 +50,8 @@ do
|
||||
|
||||
done
|
||||
|
||||
[ -f "$shutdown" ] && exit 1
|
||||
|
||||
location=$(cat "$file")
|
||||
|
||||
if [[ "$location" != "20.20"* ]]; then
|
||||
|
||||
Reference in New Issue
Block a user