#!/usr/bin/env bash # Print every CyberLux hidden-service URL (reads /var/lib/tor/*/hostname). # Tor creates these files — not Next.js. Use sudo if not readable as your user. # # bash scripts/list-onion-urls.sh # sudo bash scripts/list-onion-urls.sh # set -euo pipefail REPO="$(cd "$(dirname "$0")/.." && pwd)" TOR_DIRS="${REPO}/scripts/generated/tor-dirs.txt" if [[ ! -f "${TOR_DIRS}" ]]; then echo "Missing ${TOR_DIRS}. Run: cd ${REPO} && node scripts/generate-onion-config.cjs" exit 1 fi read_host() { local f="$1" if [[ -r "${f}" ]]; then tr -d '\n' < "${f}" elif command -v sudo >/dev/null 2>&1 && sudo test -r "${f}" 2>/dev/null; then sudo tr -d '\n' < "${f}" else echo "" fi } echo "" echo "CyberLux .onion URLs (http:// only — open in Tor Browser)" echo "────────────────────────────────────────────────────────────" while IFS= read -r d || [[ -n "${d}" ]]; do [[ -z "${d}" ]] && continue f="/var/lib/tor/${d}/hostname" host="$(read_host "${f}")" if [[ -n "${host}" ]]; then printf '%-28s http://%s\n' "${d}" "${host}" else printf '%-28s (no hostname yet — %s)\n' "${d}" "${f}" fi done < "${TOR_DIRS}" echo "────────────────────────────────────────────────────────────" echo "" echo "If lines show (no hostname yet): wait for Tor, or sudo ls -la /var/lib/tor/" echo ""