Tor docker: parameterized hostname and added command for onion hostname output

This commit is contained in:
B.J. Dweck 2020-10-22 19:16:10 +02:00
parent ab0521b401
commit cbe45426ce
3 changed files with 21 additions and 7 deletions

View File

@ -11,10 +11,9 @@ RUN apk add --no-cache curl tor && \
HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \ HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \
CMD curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations CMD curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations
COPY tor.sh /usr/bin/ COPY tor.sh /usr/local/bin/
COPY svc-hostname /usr/local/bin/
#VOLUME ["/var/lib/tor/svc"]
#USER tor #USER tor
CMD ["tor.sh"] CMD [ "tor.sh", "$SVC_HOST" ]

10
tor/svc-hostname Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
while ! curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations
do
sleep 0.5
done
echo "*****"
echo "* Service Onion Hostname: $(cat /var/lib/tor/svc/hostname)"
echo "*****"

View File

@ -1,5 +1,10 @@
#!/bin/sh #!/bin/sh
IP_BROKER=$(nslookup broker | awk '/^Address: / { print $2 }' | tail -n1 | sed -e 's/[[:space:]]//g') HOSTNAME=$1
sed -i "s/broker/$IP_BROKER/g" /etc/tor/torrc
tor IP_BROKER=$(nslookup $HOSTNAME | awk '/^Address: / { print $2 }' | tail -n1 | sed -e 's/[[:space:]]//g')
sed -i "s/$HOSTNAME/$IP_BROKER/g" /etc/tor/torrc
/usr/local/bin/svc-hostname &
tor