mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-07-14 01:45:08 +02:00
fix(build.func): parse script status without jq dependency
Replace jq-based PocketBase status parsing with sed/grep so disabled and deleted script checks work on hosts that do not have jq installed yet.
This commit is contained in:
+9
-10
@@ -3764,19 +3764,18 @@ runtime_script_status_guard() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v jq >/dev/null 2>&1; then
|
local is_deleted is_disabled deleted_message disable_message info_url
|
||||||
msg_warn "Missing jq for script status check. Continuing without status verification."
|
if printf '%s' "$response" | grep -qE '"items":[[:space:]]*\[[[:space:]]*\]'; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local has_record is_deleted is_disabled deleted_message disable_message info_url
|
# PocketBase returns a flat, fixed-field JSON blob; sed is enough here (no jq needed).
|
||||||
has_record=$(printf '%s' "$response" | jq -r '.items | length')
|
is_deleted=$(printf '%s' "$response" | sed -n 's/.*"is_deleted"[[:space:]]*:[[:space:]]*\(true\|false\).*/\1/p' | head -1)
|
||||||
[[ "$has_record" == "0" ]] && return 0
|
is_disabled=$(printf '%s' "$response" | sed -n 's/.*"is_disabled"[[:space:]]*:[[:space:]]*\(true\|false\).*/\1/p' | head -1)
|
||||||
|
deleted_message=$(printf '%s' "$response" | sed -n 's/.*"deleted_message"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
|
||||||
is_deleted=$(printf '%s' "$response" | jq -r '.items[0].is_deleted // false')
|
disable_message=$(printf '%s' "$response" | sed -n 's/.*"disable_message"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
|
||||||
is_disabled=$(printf '%s' "$response" | jq -r '.items[0].is_disabled // false')
|
is_deleted=${is_deleted:-false}
|
||||||
deleted_message=$(printf '%s' "$response" | jq -r '.items[0].deleted_message // ""')
|
is_disabled=${is_disabled:-false}
|
||||||
disable_message=$(printf '%s' "$response" | jq -r '.items[0].disable_message // ""')
|
|
||||||
info_url="https://community-scripts.org/scripts/${script_slug}"
|
info_url="https://community-scripts.org/scripts/${script_slug}"
|
||||||
|
|
||||||
if [[ "$is_deleted" == "true" ]]; then
|
if [[ "$is_deleted" == "true" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user