fix: Parse quoted values consistently (#1202)

This commit is contained in:
Peng Liu
2026-07-05 21:25:33 +02:00
committed by GitHub
parent e94a0c4a52
commit cafe619028
2 changed files with 15 additions and 10 deletions
+5 -2
View File
@@ -1,12 +1,15 @@
#!/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
[[ "$NETWORK" == [Nn]* ]] && echo "Networking is disabled." && exit 0
disabled "$NETWORK" && echo "Networking is disabled." && exit 0
file="/run/shm/dsm.url"
address="/run/shm/qemu.ip"
@@ -18,7 +21,7 @@ location=$(<"$file")
if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then
if [[ "$DHCP" == [Yy1]* ]]; then
if enabled "$DHCP"; then
ip=$(<"$address")
echo "Failed to reach DSM at http://$location"
else
+10 -8
View File
@@ -1,16 +1,19 @@
#!/usr/bin/env bash
set -Eeuo pipefail
cd /run
. utils.sh # Load functions
: "${DHCP:="N"}"
: "${NETWORK:="Y"}"
[[ "$NETWORK" == [Nn]* ]] && exit 0
disabled "$NETWORK" && exit 0
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/shm/dsm.url"
info="/run/shm/msg.html"
msgs="/run/shm/msg.html"
driver="/run/shm/qemu.nic"
page="/run/shm/index.html"
address="/run/shm/qemu.ip"
@@ -22,8 +25,7 @@ resp_err="Guest returned an invalid response:"
curl_err="Failed to connect to guest: curl error"
jq_err="Failed to parse response from guest: jq error"
while [ ! -s "$file" ]
do
while [ ! -s "$file" ]; do
# Check if not shutting down
[ -f "$shutdown" ] && exit 1
@@ -43,7 +45,7 @@ do
(( rc != 0 )) && error "$jq_err $rc ( $json )" && continue
[[ "$result" == "null" ]] && error "$resp_err $json" && continue
if [[ "$result" != "success" ]] ; then
if [[ "$result" != "success" ]]; then
{ msg=$(echo "$json" | jq -r '.message'); rc=$?; } || :
error "Guest replied $result: $msg" && continue
fi
@@ -58,7 +60,7 @@ do
[[ "$ip" == "null" ]] && error "$resp_err $json" && continue
[ -z "$ip" ] && continue
echo "$ip:$port" > $file
echo "$ip:$port" > "$file"
done
@@ -66,7 +68,7 @@ done
location=$(<"$file")
if [[ "$DHCP" == [Yy1]* ]]; then
if enabled "$DHCP"; then
msg="http://$location"
title="<title>Virtual DSM</title>"
@@ -81,7 +83,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then
HTML="${HTML/\[5\]/}"
echo "$HTML" > "$page"
echo "$body" > "$info"
echo "$body" > "$msgs"
else