From 78fa865823330ed9c5143278ad72ebd375a41a54 Mon Sep 17 00:00:00 2001 From: red Date: Sun, 30 Jan 2022 12:28:43 +0100 Subject: [PATCH] cleanup bridge --- Dockerfile.bridge | 5 ++--- conf/supervisord.conf | 15 --------------- scripts/bridge.sh | 23 ----------------------- scripts/entrypoint.sh | 7 ++++++- 4 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 conf/supervisord.conf delete mode 100755 scripts/bridge.sh diff --git a/Dockerfile.bridge b/Dockerfile.bridge index 04a0016..8cdf563 100644 --- a/Dockerfile.bridge +++ b/Dockerfile.bridge @@ -3,13 +3,12 @@ ARG FROM_VERSION=latest FROM ${FROM_IMAGE}:${FROM_VERSION} -RUN apk add --no-cache --purge --clean-protected supervisor iptables \ - && mkdir -p /var/log/supervisor \ +RUN apk add --no-cache --purge --clean-protected iptables \ && rm -rf /var/cache/apk/* ENV LOG_PATH=/var/log/supervisor -COPY conf scripts /opt +COPY scripts /opt EXPOSE 9993/udp diff --git a/conf/supervisord.conf b/conf/supervisord.conf deleted file mode 100644 index b36c1b3..0000000 --- a/conf/supervisord.conf +++ /dev/null @@ -1,15 +0,0 @@ -[supervisord] -nodaemon=true -user=root -logfile=%(ENV_LOG_PATH)s/supervisord.log -childlogdir=%(ENV_LOG_PATH)s -priority=1 - -[program:bridge] -command=/opt/bridge.sh -stdout_logfile=%(ENV_LOG_PATH)s/bridge.stdout.log -stderr_logfile=%(ENV_LOG_PATH)s/bridge.stderr.log -startsecs=0 -autorestart=false -exitcodes=0 -priority=1 \ No newline at end of file diff --git a/scripts/bridge.sh b/scripts/bridge.sh deleted file mode 100755 index 5ed3bd3..0000000 --- a/scripts/bridge.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env sh - -set -o errexit -set -o pipefail -set -o nounset -# set -o xtrace - -echo "Waiting for network interface to be ready..." - -while ! ifconfig | grep -q zt; do - echo -n "." - sleep 1 -done - -echo "Network interface is ready. Starting bridge..." - -PHY_IFACE=eth0 -ZT_IFACE=$(ifconfig | grep zt | awk '{print $1}') -iptables -t nat -A POSTROUTING -o $PHY_IFACE -j MASQUERADE -iptables -A FORWARD -i $PHY_IFACE -o $ZT_IFACE -m state --state RELATED,ESTABLISHED -j ACCEPT -iptables -A FORWARD -i $ZT_IFACE -o $PHY_IFACE -j ACCEPT - -echo "Bridge started." \ No newline at end of file diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 6a89126..ecd8889 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,4 +1,9 @@ #!/usr/bin/env sh -/usr/bin/supervisord --configuration /opt/supervisord.conf & +PHY_IFACE=eth0 +ZT_IFACE="zt+" +iptables -t nat -A POSTROUTING -o $PHY_IFACE -j MASQUERADE +iptables -A FORWARD -i $PHY_IFACE -o $ZT_IFACE -m state --state RELATED,ESTABLISHED -j ACCEPT +iptables -A FORWARD -i $ZT_IFACE -o $PHY_IFACE -j ACCEPT + zerotier-one $@ \ No newline at end of file