Browse Source

fill torrc template with envsubst

Fabian Peter Hammerle 3 years ago
parent
commit
869b5f4d10
4 changed files with 9 additions and 9 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 1
      Dockerfile
  3. 2 6
      entrypoint.sh
  4. 2 2
      torrc.template

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - changed log level of `control` domain to `warn`
   (to avoid log spam by healthcheck connecting to control listener)
 - added message domains to log messages
+- fill `torrc` template with `envsubst`
 
 ### Removed
 - disabled socks proxy

+ 4 - 1
Dockerfile

@@ -1,7 +1,10 @@
 FROM alpine:3.12
 
+ARG GETTEXT_PACKAGE_VERSION=0.20.2-r0
 ARG TOR_PACKAGE_VERSION=0.4.3.5-r0
-RUN apk add --no-cache tor=$TOR_PACKAGE_VERSION \
+RUN apk add --no-cache \
+        tor=$TOR_PACKAGE_VERSION \
+        gettext=$GETTEXT_PACKAGE_VERSION \
     && mkdir -m u=rwx,g=,o= /onion-service \
     && chown tor /onion-service
 VOLUME /var/lib/tor

+ 2 - 6
entrypoint.sh

@@ -1,11 +1,7 @@
 #!/bin/sh
 
-set -eux
+set -eu
 
-# alternative: https://pkgs.alpinelinux.org/contents?file=envsubst&path=&name=&branch=v3.12
-sed -e "s#{version}#$VERSION#" \
-    -e "s#{virtual_port}#$VIRTUAL_PORT#" \
-    -e "s#{target}#$TARGET#" \
-    /torrc.template >/tmp/torrc
+envsubst </torrc.template >/tmp/torrc
 
 exec "$@"

+ 2 - 2
torrc.template

@@ -13,8 +13,8 @@ SocksPort 0
 
 # https://www.torproject.org/docs/tor-onion-service
 HiddenServiceDir /onion-service
-HiddenServiceVersion {version}
-HiddenServicePort {virtual_port} {target}
+HiddenServiceVersion $VERSION
+HiddenServicePort $VIRTUAL_PORT $TARGET
 
 # try to
 HardwareAccel 1