mirror of
https://github.com/AuxXxilium/arv-v-dsm.git
synced 2024-11-23 23:10:58 +07:00
parent
03d2665725
commit
b9f3e52ba4
@ -20,4 +20,4 @@ services:
|
||||
volumes:
|
||||
- /opt/dsm:/storage
|
||||
restart: on-failure
|
||||
stop_grace_period: 1m
|
||||
stop_grace_period: 2m
|
||||
|
@ -41,7 +41,7 @@ services:
|
||||
volumes:
|
||||
- /opt/dsm:/storage
|
||||
restart: on-failure
|
||||
stop_grace_period: 1m
|
||||
stop_grace_period: 2m
|
||||
```
|
||||
|
||||
Via `docker run`
|
||||
|
@ -5,12 +5,12 @@ set -Eeuo pipefail
|
||||
[ -f "/run/qemu.count" ] && echo "QEMU is shutting down.." && exit 1
|
||||
|
||||
file="/run/dsm.url"
|
||||
url="http://127.0.0.1:2210/read?command=10"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
|
||||
# Retrieve IP from guest VM for Docker healthcheck
|
||||
|
||||
{ json=$(curl -m 30 -sk http://127.0.0.1:2210/read?command=10); rc=$?; } || :
|
||||
{ json=$(curl -m 20 -sk "$url"); rc=$?; } || :
|
||||
(( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1
|
||||
|
||||
{ result=$(echo "$json" | jq -r '.status'); rc=$?; } || :
|
||||
|
@ -156,11 +156,15 @@ closeNetwork () {
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
|
||||
{ pkill -f server.sh || true; } 2>/dev/null
|
||||
|
||||
ip link set "$VM_NET_TAP" down || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
else
|
||||
|
||||
{ pkill -f dnsmasq || true; } 2>/dev/null
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
|
@ -33,11 +33,12 @@ _graceful_shutdown() {
|
||||
# echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null
|
||||
|
||||
# Send shutdown command to guest agent via serial port
|
||||
response=$(curl -sk -m 30 -S http://127.0.0.1:2210/read?command=6 2>&1)
|
||||
url="http://127.0.0.1:2210/read?command=6&timeout=50"
|
||||
response=$(curl -sk -m 60 -S "$url" 2>&1)
|
||||
|
||||
if [[ ! "$response" =~ "\"success\"" ]]; then
|
||||
|
||||
echo && error "Failed to send shutdown command ( $response )."
|
||||
echo && error "Failed to send shutdown command (${response#*message\"\: \"})."
|
||||
|
||||
kill -15 "$(cat "$QEMU_PID")"
|
||||
pkill -f qemu-system-x86_64 || true
|
||||
@ -64,7 +65,9 @@ _graceful_shutdown() {
|
||||
echo && echo "❯ Quitting..."
|
||||
echo 'quit' | nc -q 1 -w 1 localhost "$QEMU_PORT" >/dev/null 2>&1 || true
|
||||
|
||||
pkill -f host.bin || true
|
||||
closeNetwork
|
||||
sleep 1
|
||||
|
||||
return
|
||||
}
|
||||
|
10
src/print.sh
10
src/print.sh
@ -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=$?; } || :
|
||||
|
Loading…
Reference in New Issue
Block a user