fix issue with missing /etc/torrc.d/*

This commit is contained in:
Shahrad Elahi 2023-12-11 04:06:15 +03:30
parent ee2f5808b8
commit 4aa94a787c
4 changed files with 23 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}"