regtest/lnbits-entrypoint.sh
Padreug e404b7ee11
Some checks are pending
ci / regtest (push) Waiting to run
regtest: rename castle → libra in default-installed extensions
The castle LNbits extension was renamed to libra. Updates the
default-install / default-user env vars in docker-compose.dev.yml
and the fava-url pin in lnbits-entrypoint.sh (DB filename, slug,
log prefix, comments). The entrypoint script was previously
untracked — tracking it now so the rename persists for fresh
checkouts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 20:44:47 +02:00

40 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
# Wraps the lnbits CMD to keep libra's fava_url pinned at the docker-network
# address `http://fava:5000`. Libra persists the URL in
# /app/data/ext_libra.sqlite3 (extension_settings.fava_url) and the model
# default is "http://localhost:3333", which doesn't resolve from inside the
# lnbits container.
#
# Background loop polls until the table exists, then UPSERTs the row, then
# exits. Runs alongside the lnbits process so it lands before libra's async
# _init_fava() task reads the row on a fresh DB.
set -e
(
while true; do
if [ -f /app/data/ext_libra.sqlite3 ]; then
python3 -c '
import sqlite3, sys, time
try:
con = sqlite3.connect("/app/data/ext_libra.sqlite3")
con.execute(
"INSERT INTO extension_settings (id, fava_url, fava_ledger_slug, fava_timeout, updated_at) "
"VALUES (?, ?, ?, ?, ?) "
"ON CONFLICT(id) DO UPDATE SET fava_url=excluded.fava_url, updated_at=excluded.updated_at",
("admin", "http://fava:5000", "libra-ledger", 10.0, time.time()),
)
con.commit()
print("[libra-fava-url-init] fava_url=http://fava:5000", flush=True)
except sqlite3.OperationalError:
sys.exit(1)
' && break
fi
sleep 0.5
done
) &
exec uv --offline run lnbits \
--port "${LNBITS_PORT:-5001}" \
--host "${LNBITS_HOST:-0.0.0.0}" \
--forwarded-allow-ips='*'