33 lines
2.4 KiB
Bash
Executable file
33 lines
2.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Publish the rented-GPU fleet page's data: copies a fleet.json into the downloads site's fleet folder and deploys.
|
|
# tools/fleet/publish-fleet.sh <fleet.json> (the fleet agent calls this after every change, at most once a minute)
|
|
# The folder name is in ~/.config/igneum/fleet-path; the page is dl.igneum.network/<that path>/ (noindex, unlisted).
|
|
set -euo pipefail
|
|
JSON="${1:?fleet.json path}"
|
|
DLSITE="$(cat "$HOME/.config/igneum/dlsite-dir")"; P="$(cat "$HOME/.config/igneum/fleet-path")"
|
|
python3 -c "import json,sys; json.load(open(sys.argv[1]))" "$JSON"
|
|
cp "$JSON" "$DLSITE/$P/fleet.json"
|
|
# The Fleet | Workers nav is part of the page for good (6 October 2026, the project lead: the link was missing): re-insert it and its
|
|
# four CSS lines whenever an index.html regeneration dropped them. Absolute paths: the host serves the folder without a slash.
|
|
python3 - "$DLSITE/$P/index.html" "$P" <<'PY'
|
|
import sys, re
|
|
f, p = sys.argv[1], sys.argv[2]; s = open(f).read()
|
|
nav = f'<nav aria-label="Pages"><a href="/{p}/" class="on" aria-current="page">Fleet</a><a href="/{p}/workers.html">Workers</a></nav>'
|
|
css = """ nav { display: flex; gap: 2px; border: 1px solid var(--line); }
|
|
nav a { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); text-decoration: none; padding: 7px 12px; }
|
|
nav a.on { color: var(--ink); background: var(--panel-2); }
|
|
nav a:hover { color: var(--ember-2); }
|
|
"""
|
|
changed = False
|
|
if "nav {" not in s: s = s.replace("</style>", css + "</style>", 1); changed = True
|
|
if "workers.html" not in s:
|
|
m = re.search(r"<header[^>]*>", s) or re.search(r"<body[^>]*>", s)
|
|
s = s[:m.end()] + "\n " + nav + s[m.end():]; changed = True
|
|
if changed: open(f, "w").write(s); print("fleet index.html: nav restored")
|
|
PY
|
|
(cd "$DLSITE" && npx --yes vercel@latest --global-config "$HOME/.config/igneum/vercel" deploy --prod --yes >/dev/null 2>&1) || { echo "deploy failed" >&2; exit 1; }
|
|
for i in $(seq 1 12); do
|
|
if curl -fsS --max-time 10 "https://dl.igneum.network/$P/fleet.json?t=$(date +%s)" | python3 -c "import json,sys; d=json.load(sys.stdin); sys.exit(0 if d.get('spend',{}).get('updated_at')==json.load(open('$JSON')).get('spend',{}).get('updated_at') else 1)" 2>/dev/null; then echo "live: https://dl.igneum.network/$P/"; exit 0; fi
|
|
sleep 5
|
|
done
|
|
echo "deployed but the edge still serves the previous file" >&2; exit 2
|