From b3a3d3f9a8755a2765b96c87c403106598d837c6 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 31 Mar 2026 04:33:55 +0100 Subject: [PATCH] fix: populate tor-hostnames dir in first-boot for backend onion discovery Backend reads onion addresses from /var/lib/archipelago/tor-hostnames/. This dir was never created on fresh installs, breaking connect wallet and tor address display. Now copies from system Tor hidden service dirs. Also fixed log() function ordering. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/first-boot-containers.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/first-boot-containers.sh b/scripts/first-boot-containers.sh index 2aeab34e..7816e0fa 100644 --- a/scripts/first-boot-containers.sh +++ b/scripts/first-boot-containers.sh @@ -32,12 +32,14 @@ SCRIPT_DIR_FBC="$(cd "$(dirname "$0")" && pwd)" TARGET_IP=$(hostname -I 2>/dev/null | awk '{print $1}') [ -z "$TARGET_IP" ] && TARGET_IP="127.0.0.1" +log() { echo "$(date '+%Y-%m-%d %H:%M:%S') $*" | tee -a "$LOG"; } + # Ensure Tor is running for hidden services (LND connect, Electrumx, etc.) if ! systemctl is-active tor >/dev/null 2>&1; then log "Starting Tor..." systemctl enable tor 2>/dev/null || true systemctl start tor 2>/dev/null || true - sleep 3 + sleep 5 if systemctl is-active tor >/dev/null 2>&1; then log " Tor started successfully" else @@ -45,7 +47,19 @@ if ! systemctl is-active tor >/dev/null 2>&1; then fi fi -log() { echo "$(date '+%Y-%m-%d %H:%M:%S') $*" | tee -a "$LOG"; } +# Populate tor-hostnames directory so the backend can read onion addresses +# The backend reads from /var/lib/archipelago/tor-hostnames/{service} at startup +TOR_HOSTNAMES="/var/lib/archipelago/tor-hostnames" +mkdir -p "$TOR_HOSTNAMES" +for svc in archipelago bitcoin lnd electrumx btcpay mempool fedimint; do + for dir in /var/lib/tor/hidden_service_${svc}; do + if [ -f "$dir/hostname" ]; then + cp "$dir/hostname" "$TOR_HOSTNAMES/$svc" 2>/dev/null + fi + done +done +chown -R archipelago:archipelago "$TOR_HOSTNAMES" 2>/dev/null +log "Tor hostnames populated: $(ls $TOR_HOSTNAMES 2>/dev/null | tr '\n' ' ')" # Wait for a container to be healthy (accepting connections) wait_for_container() {