feat: save onion addresses to file and .env on host

- entrypoint.sh: background process writes onion-hosts.txt with SSH_ONION and ADMIN_ONION
- docker-compose.yml: bind mount tor-proxy/hosts for onion address persistence on host
- tor-proxy/get-onions.sh: reads onion addresses and updates .env with ADMIN_URL, SSH_ONION, ADMIN_ONION
- .gitignore: exclude tor-proxy/hosts/onion-hosts.txt (secret)
- tor-proxy/hosts/.gitkeep: ensure directory exists in git
This commit is contained in:
NW
2026-06-24 11:45:43 +01:00
parent d8bfb29205
commit 67c1436670
5 changed files with 96 additions and 0 deletions

View File

@@ -53,5 +53,31 @@ EOF
echo "torrc contents:"
cat /etc/tor/torrc
mkdir -p /onion-hosts
( \
echo "Waiting for onion addresses..."; \
for i in $(seq 1 120); do \
SSH_H=""; ADMIN_H=""; \
[ -s /var/lib/tor/ssh/hostname ] && SSH_H=$(cat /var/lib/tor/ssh/hostname); \
[ -s /var/lib/tor/admin/hostname ] && ADMIN_H=$(cat /var/lib/tor/admin/hostname); \
if [ -n "$SSH_H" ] && [ -n "$ADMIN_H" ]; then \
cat > /onion-hosts/onion-hosts.txt <<CONF
# Tor Onion Addresses - auto-generated at $(date -u +%Y-%m-%dT%H:%M:%SZ)
# Do not edit manually - overwritten on container restart
SSH_ONION=${SSH_H}
ADMIN_ONION=${ADMIN_H}
# Usage:
# SSH: torify ssh user@${SSH_H}
# Admin: open http://${ADMIN_H} in Tor Browser
CONF
echo "Onion addresses saved to /onion-hosts/onion-hosts.txt"; \
exit 0; \
fi; \
sleep 2; \
done; \
echo "WARNING: Timed out waiting for onion addresses"; \
) &
echo "Starting Tor..."
exec tor -f /etc/tor/torrc