This commit was merged in pull request #53.
This commit is contained in:
@@ -67,9 +67,15 @@ print_export_template() {
|
||||
# ─── Step 1: Confirm LNbits is reachable ─────────────────────────────────────
|
||||
|
||||
info "Checking LNbits at $LNBITS_LOCAL …"
|
||||
HEALTH_JSON="$(curl -sf --max-time 6 "$LNBITS_LOCAL/api/v1/health" 2>/dev/null || true)"
|
||||
|
||||
if [[ -z "$HEALTH_JSON" ]]; then
|
||||
# Use a plain GET to the root URL to test reachability (works on all versions).
|
||||
# The health endpoint (/api/v1/health) only exists on 0.12+.
|
||||
LNBITS_REACHABLE=false
|
||||
if curl -sf --max-time 6 -o /dev/null "$LNBITS_LOCAL/" 2>/dev/null; then
|
||||
LNBITS_REACHABLE=true
|
||||
fi
|
||||
|
||||
if [[ "$LNBITS_REACHABLE" != "true" ]]; then
|
||||
warn "LNbits is not reachable at $LNBITS_LOCAL (is it running?)."
|
||||
warn "Showing manual setup instructions — run this script again once LNbits is up."
|
||||
echo ""
|
||||
@@ -80,18 +86,30 @@ if [[ -z "$HEALTH_JSON" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ok "LNbits is reachable at $LNBITS_LOCAL"
|
||||
|
||||
# ─── Step 2: Detect LNbits version ───────────────────────────────────────────
|
||||
|
||||
# Try the health endpoint (available on 0.12+) to get the server version.
|
||||
HEALTH_JSON="$(curl -sf --max-time 6 "$LNBITS_LOCAL/api/v1/health" 2>/dev/null || true)"
|
||||
|
||||
LNBITS_VERSION=""
|
||||
if command -v python3 &>/dev/null; then
|
||||
if [[ -n "$HEALTH_JSON" ]] && command -v python3 &>/dev/null; then
|
||||
LNBITS_VERSION="$(echo "$HEALTH_JSON" \
|
||||
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('server_version',''))" \
|
||||
2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
if [[ -z "$LNBITS_VERSION" ]]; then
|
||||
warn "Could not parse server_version from health endpoint — assuming modern LNbits (>= 0.12)."
|
||||
LNBITS_VERSION="0.12.0"
|
||||
if [[ -z "$HEALTH_JSON" ]]; then
|
||||
# Health endpoint not found — this is a pre-0.12 LNbits that lacks /api/v1/health.
|
||||
warn "Health endpoint not available — assuming legacy LNbits (< 0.12)."
|
||||
LNBITS_VERSION="0.11.0"
|
||||
else
|
||||
# Health endpoint responded but didn't include server_version.
|
||||
warn "Could not parse server_version from health endpoint — assuming modern LNbits (>= 0.12)."
|
||||
LNBITS_VERSION="0.12.0"
|
||||
fi
|
||||
fi
|
||||
|
||||
info "LNbits version: ${LNBITS_VERSION}"
|
||||
|
||||
Reference in New Issue
Block a user