Skip to content

Commit ec6ed9a

Browse files
committed
Added interface name parameter
1 parent bfd2386 commit ec6ed9a

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
### 2.0.2 - Added multi-instance support
4+
5+
- Added `TUNNEL_INTERFACE` to set interface name (in case of multiple containers)
6+
- Some fixes for general user
7+
38
### 2.0.1 - Fix service start
49

510
- Fixed command for starting service

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ ENV EASYRSA=/usr/share/easy-rsa \
4343
EASYRSA_VARS_FILE=/config/ssl/vars \
4444
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
4545
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
46-
EASYRSA_TEMP_FILE=/config/tmp/temp
46+
EASYRSA_TEMP_FILE=/config/tmp/temp \
47+
TUNNEL_INTERFACE="tun0"
4748

4849
# Install packages
4950
RUN apk add --no-cache \

Dockerfile.armhf

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ ENV EASYRSA=/usr/share/easy-rsa \
4343
EASYRSA_VARS_FILE=/config/ssl/vars \
4444
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
4545
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
46-
EASYRSA_TEMP_FILE=/config/tmp/temp
46+
EASYRSA_TEMP_FILE=/config/tmp/temp \
47+
TUNNEL_INTERFACE="tun0"
4748

4849
# Install packages
4950
RUN apk add --no-cache \

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ services:
7070
|`-e PUID=1000`|for UserID - see below for explanation|
7171
|`-e PGID=1000`|for GroupID - see below for explanation|
7272
|`-e PERSISTENT_INTERFACE=true`|Enable persistent TUN interface|
73+
|`-e TUNNEL_INTERFACE="tun0"`|Tunnel interface name (default: tun0)|
7374
|`-e USE_FIREWALL=false`|Disable any firewall related rules to be created, modified ... (must be implemented in example)|
7475
|`-v /config`|All the config files including OpenVPNs reside here|
7576
|`-v /log`|Log files reside here|

root/etc/cont-finish.d/60-network.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
# Delete tunnel interface (if not persistant)
8-
if [ -n "$(cat /proc/net/dev | grep tun0)" ] && { [ -z "$PERSISTENT_INTERFACE" ] || [ "$PERSISTENT_INTERFACE" != "true" ]; }; then
9-
echo "Removing tun0 interface"
10-
openvpn --rmtun --dev tun0
8+
if [ -n "$(cat /proc/net/dev | grep $TUNNEL_INTERFACE)" ] && { [ -z "$PERSISTENT_INTERFACE" ] || [ "$PERSISTENT_INTERFACE" != "true" ]; }; then
9+
echo "Removing $TUNNEL_INTERFACE interface"
10+
openvpn --rmtun --dev $TUNNEL_INTERFACE
1111
fi

root/etc/cont-init.d/60-network.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ if [ ! -c "/dev/net/tun" ]; then
1919
fi
2020

2121
# Remove existing interface if not persistent interface selected
22-
if [ -n "$(cat /proc/net/dev | grep tun0)" ] && { [ -z "$PERSISTENT_INTERFACE" ] || [ "$PERSISTENT_INTERFACE" != "true" ]; }; then
23-
echo "Removing tun0 interface"
24-
openvpn --rmtun --dev tun0
22+
if [ -n "$(cat /proc/net/dev | grep $TUNNEL_INTERFACE)" ] && { [ -z "$PERSISTENT_INTERFACE" ] || [ "$PERSISTENT_INTERFACE" != "true" ]; }; then
23+
echo "Removing $TUNNEL_INTERFACE interface"
24+
openvpn --rmtun --dev $TUNNEL_INTERFACE
2525
fi
2626

2727
# Create tunnel interface
28-
if [ -z "$(cat /proc/net/dev | grep tun0)" ]; then
29-
echo "Creating tun0 interface"
30-
openvpn --mktun --dev tun0 --dev-type tun --user abc --group abc
28+
if [ -z "$(cat /proc/net/dev | grep $TUNNEL_INTERFACE)" ]; then
29+
echo "Creating $TUNNEL_INTERFACE interface"
30+
openvpn --mktun --dev $TUNNEL_INTERFACE --dev-type tun --user $CONTAINER_USER --group $CONTAINER_USER
3131
fi

0 commit comments

Comments
 (0)