From 96c041896b3811409291f888324f88b923df0bcd Mon Sep 17 00:00:00 2001 From: strophy <32928115+strophy@users.noreply.github.com> Date: Wed, 2 Jun 2021 19:54:57 +0200 Subject: [PATCH] feat: add tor entrypoint script for use in dashmate (#4182) * feat: add entrypoint for tor features in dashmate * fix: use spaces consistently for indendation * fix: output blank line after info * fix: ensure script is executable * fix: keep linter happy --- docker/Dockerfile.GitHubActions | 3 +++ docker/docker-entrypoint.sh | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 docker/docker-entrypoint.sh diff --git a/docker/Dockerfile.GitHubActions b/docker/Dockerfile.GitHubActions index ec161c518e..ba387dbb3d 100644 --- a/docker/Dockerfile.GitHubActions +++ b/docker/Dockerfile.GitHubActions @@ -34,6 +34,9 @@ USER dash VOLUME ["/dash"] +COPY docker-entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] + EXPOSE 9998 9999 19998 19999 WORKDIR /dash diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100755 index 0000000000..a201ae7e18 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +export LC_ALL=C +set -e + +# Get Tor service IP if running +if [[ "$1" == "dashd" ]]; then + # Because dashd only accept torcontrol= host as an ip only, we resolve it here and add to config + if [[ "$TOR_CONTROL_HOST" ]] && [[ "$TOR_CONTROL_PORT" ]] && [[ "$TOR_PROXY_PORT" ]]; then + TOR_IP=$(getent hosts $TOR_CONTROL_HOST | cut -d ' ' -f 1) + echo "proxy=$TOR_IP:$TOR_PROXY_PORT" >> "$HOME/.dashcore/dash.conf" + echo "Added "proxy=$TOR_IP:$TOR_PROXY_PORT" to $HOME/.dashcore/dash.conf" + echo "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" >> "$HOME/.dashcore/dash.conf" + echo "Added "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" to $HOME/.dashcore/dash.conf" + echo -e "\n" + else + echo "Tor control credentials not provided" + fi +fi + +exec "$@"