From 7a61220aa509ee6f1895ad4f5d68d9726495344c Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 28 Oct 2020 22:18:29 -0400 Subject: [PATCH] Update Dockerfile tor service init, refactor rc/ -> misc/ The tor service is now started by calling a script which runs tor according to the current container user. If the user is root, the script will begin the tor service as normal. Otherwise, it runs tor as the current user. This primarily is meant to address the issue with Heroku builds (which don't have a root user) not being able to start tor as a service. Also refactored the rc/ dir to misc/ (with a tor/ subdir) since that makes more sense. --- Dockerfile | 4 ++-- misc/tor/start-tor.sh | 7 +++++++ {rc => misc/tor}/torrc | 0 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100755 misc/tor/start-tor.sh rename {rc => misc/tor}/torrc (100%) diff --git a/Dockerfile b/Dockerfile index 0882bad..bf038ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ tor -COPY rc/torrc /etc/tor/torrc +COPY misc/tor/torrc /etc/tor/torrc COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt @@ -40,4 +40,4 @@ COPY . . EXPOSE $EXPOSE_PORT -CMD service tor start && ./run +CMD misc/tor/start-tor.sh & ./run diff --git a/misc/tor/start-tor.sh b/misc/tor/start-tor.sh new file mode 100755 index 0000000..19be24a --- /dev/null +++ b/misc/tor/start-tor.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ "$(whoami)" != "root" ]; then + tor -f /etc/tor/torrc +else + service tor start +fi diff --git a/rc/torrc b/misc/tor/torrc similarity index 100% rename from rc/torrc rename to misc/tor/torrc