diff options
author | Linus Nordberg <linus@nordberg.se> | 2015-05-26 15:18:54 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2015-05-26 15:18:54 +0200 |
commit | a8126b37d4ef973092c1adf4d8238509de21542b (patch) | |
tree | 3c3ba32ac71e3df7c3744e3ac84a21be3ec344b2 /onion |
Initial commit.
Diffstat (limited to 'onion')
-rw-r--r-- | onion/Dockerfile | 11 | ||||
-rw-r--r-- | onion/start.sh | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/onion/Dockerfile b/onion/Dockerfile new file mode 100644 index 0000000..c1cadcd --- /dev/null +++ b/onion/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:jessie +RUN apt-get update +RUN echo 'debconf debconf/frontend select noninteractive' | debconf-set-selections +RUN apt-get -y -q install tor +RUN systemctl disable tor +ADD start.sh /start.sh +RUN chmod a+rx /start.sh +VOLUME /etc/tor +VOLUME /var/lib/tor/hs +RUN chown -R debian-tor:debian-tor /var/lib/tor/hs +ENTRYPOINT ["/start.sh"] diff --git a/onion/start.sh b/onion/start.sh new file mode 100644 index 0000000..dce48af --- /dev/null +++ b/onion/start.sh @@ -0,0 +1,20 @@ +#! /bin/sh + +# BACKEND_PORT is set by `docker run --link BACKEND:foo' on the form +# tcp://<ip>:<port>. See https://docs.docker.com/userguide/dockerlinks/. + +if [ -n "${HSPORT}" ]; then + HSPORT=80 # Default localhost:80 -> .onion:80 + if [ -n "${BACKEND_PORT}" ]; then + HSPORT="80 "$(echo ${BACKEND_PORT} | sed 's|^.*://||1') + fi +fi + +if ! [ -e /etc/tor/torrc ]; then + echo "SocksPort 0" >> /etc/tor/torrc + echo "DataDirectory /var/lib/tor" >> /etc/tor/torrc + echo "HiddenServiceDir /var/lib/tor/hs" >> /etc/tor/torrc + echo "HiddenServicePort ${HSPORT}" >> /etc/tor/torrc +fi + +/usr/bin/tor -f /etc/tor/torrc --user debian-tor |