34 lines
1.6 KiB
Bash
34 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
OUT="/var/www/EFT_COMPANION/public_html/quests.json"
|
|
ENDPOINT="https://api.tarkov.dev/graphql"
|
|
|
|
# Use a single-line GraphQL query to avoid escaping headaches
|
|
# (Also removed fields that caused schema errors: Skill.normalizedName, craftUnlock.name)
|
|
QUERY='query AllTasks { tasks { id name trader { id name imageLink } wikiLink objectives { id type description maps { normalizedName } ... on TaskObjectiveItem { count foundInRaid item { id name shortName iconLink } items { id name shortName iconLink } } ... on TaskObjectiveShoot { targetNames count } } finishRewards { items { count item { id name shortName iconLink } } traderStanding { standing trader { id name } } offerUnlock { item { id name } trader { id name } } skillLevelReward { level skill { id name } } traderUnlock { id name } craftUnlock { id } achievement { id name } customization { id name } } } }'
|
|
|
|
# Build minimal JSON payload without external tools (query has no double quotes)
|
|
PAYLOAD=$(printf '{"query":"%s"}' "$QUERY")
|
|
|
|
# Write to a temp file in the same directory, then atomically mv into place
|
|
TMP="$(mktemp -p /var/www/EFT_COMPANION/public_html/quests.json.tmp.XXXXXX)"
|
|
|
|
echo "[update-quests] Posting to $ENDPOINT ..."
|
|
HTTP_STATUS="$(curl -sS -o "$TMP" -w '%{http_code}' \
|
|
-X POST "$ENDPOINT" \
|
|
-H 'Content-Type: application/json' \
|
|
--data-binary "$PAYLOAD")"
|
|
|
|
if [ "$HTTP_STATUS" != "200" ]; then
|
|
echo "[update-quests] ERROR: HTTP $HTTP_STATUS"
|
|
echo "[update-quests] Response body (first 2000 bytes):"
|
|
head -c 2000 "$TMP"; echo
|
|
rm -f "$TMP"
|
|
exit 1
|
|
fi
|
|
|
|
chmod 0644 "$TMP"
|
|
mv -f "$TMP" "$OUT"
|
|
echo "[update-quests] Wrote $OUT at $(date -Is)"
|