diff --git a/Dockerfile b/Dockerfile index 9b693d8..554bdec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,10 @@ ENTRYPOINT ["/entrypoint.sh"] HEALTHCHECK --interval=60s --timeout=3s --start-period=20s --retries=3 \ CMD curl -f http://127.0.0.1:3000/api/health || exit 1 -VOLUME ["/etc/torrc.d"] +RUN mkdir -p /data && chmod 700 /data +RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d + +VOLUME ["/etc/torrc.d", "/data"] # run the app EXPOSE 3000/tcp diff --git a/Dockerfile-Dev b/Dockerfile-Dev index e712f7b..45fc857 100644 --- a/Dockerfile-Dev +++ b/Dockerfile-Dev @@ -45,7 +45,10 @@ COPY docker-entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] -VOLUME ["/etc/torrc.d"] +RUN mkdir -p /data && chmod 700 /data +RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d + +VOLUME ["/etc/torrc.d", "/data"] # run the appc EXPOSE 5173/tcp diff --git a/config/torrc b/config/torrc index 3d1e252..e50e0f0 100644 --- a/config/torrc +++ b/config/torrc @@ -1,4 +1,4 @@ -# This file is auto generated by the WireAdmin. Do not edit. +##### Auto-Generated by the WireAdmin. Do not edit. ##### VirtualAddrNetwork 10.192.0.0/10 DNSPort {{INET_ADDRESS}}:53530 TransPort {{INET_ADDRESS}}:9040 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1610773..53b95b1 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -22,14 +22,12 @@ to_camel_case() { echo "${1}" | awk -F_ '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1' OFS="" } -# Checking if there is /data folder -if [ ! -d "/data" ]; then - mkdir -p /data - chmod 700 /data +mkdir -p /var/vlogs + +if [ ! -f "${ENV_FILE}" ]; then + echo "" >"${ENV_FILE}" fi -mkdir -p /var/vlogs -touch "${ENV_FILE}" chmod 400 "${ENV_FILE}" if ! grep -q "AUTH_SECRET" "${ENV_FILE}"; then @@ -71,12 +69,20 @@ remove_duplicated_lines "${TOR_CONFIG}" # Checking if there is /etc/torrc.d folder and if there is # any file in it, adding them to the torrc file -if [ -d "/etc/torrc.d" ]; then - for file in /etc/torrc.d/*; do +TORRC_DIR_FILES=$(find /etc/torrc.d -type f -name "*.conf") +if [ -n "$TORRC_DIR_FILES" ]; then + for file in $TORRC_DIR_FILES; do cat "$file" >>"${TOR_CONFIG}" done fi +# Remove comment line with single Hash +sed -i '/^#\([^#]\)/d' "${TOR_CONFIG}" +# Remove options with no value. (KEY[:space:]{...VALUE}) +sed -i '/^[^ ]* $/d' "${TOR_CONFIG}" +# Remove double empty lines +sed -i '/^$/N;/^\n$/D' "${TOR_CONFIG}" + # Start Tor on the background screen -L -Logfile /var/vlogs/tor -dmS tor \ bash -c "tor -f ${TOR_CONFIG}"