From 213eb198698ae32e5ebc715a7fbe36d78894165a Mon Sep 17 00:00:00 2001 From: iLTeoooD Date: Sun, 9 Jan 2022 14:47:05 +0100 Subject: [PATCH] Tun device gration --- .gitignore | 1 + Dockerfile | 1 + README.md | 1 + startup.sh | 8 ++++++++ 4 files changed, 11 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index abe611d..5b0e8d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ENV SURFSHARK_CITY= ENV OPENVPN_OPTS= ENV CONNECTION_TYPE=tcp ENV LAN_NETWORK= +ENV CREATE_TUN_DEVICE= HEALTHCHECK --interval=60s --timeout=10s --start-period=30s CMD curl -L 'https://ipinfo.io' COPY startup.sh . RUN apk add --update --no-cache openvpn wget unzip coreutils curl && chmod +x ./startup.sh diff --git a/README.md b/README.md index ac008cd..63f20ae 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The container is configurable using 5 environment variables: |OPENVPN_OPTS|No|Any additional options for OpenVPN| |CONNECTION_TYPE|No|The connection type that you want to use: tcp, udp| |LAN_NETWORK|No|Lan network used to access the web ui of attached containers. Can be comma seperated for multiple subnets Comment out or leave blank: example 192.168.0.0/24| +|CREATE_TUN_DEVICE|No|Creates the TUN device, useful for NAS users| `SURFSHARK_USER` and `SURFSHARK_PASSWORD` are provided at the bottom of this page: [https://account.surfshark.com/setup/manual](https://account.surfshark.com/setup/manual). diff --git a/startup.sh b/startup.sh index 2e5a1ac..d790523 100644 --- a/startup.sh +++ b/startup.sh @@ -21,4 +21,12 @@ then echo Do not forget to expose the ports for attached container we ui access fi + +if [ "${CREATE_TUN_DEVICE}" = "true" ]; then + echo "Creating TUN device /dev/net/tun" + mkdir -p /dev/net + mknod /dev/net/tun c 10 200 + chmod 0666 /dev/net/tun +fi + openvpn --config $VPN_FILE --auth-user-pass vpn-auth.txt --mute-replay-warnings $OPENVPN_OPTS