Skip to content

Commit 533bc7c

Browse files
authored
feat: run optional user startup script (#3)
Signed-off-by: Aurora Gaffney <aurora@blinklabs.io>
1 parent 579e0f7 commit 533bc7c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ There is no default config provided by the image, so you'll need to provide your
99
```
1010
docker run -d -n openvpn -v /path/to/openvpn.conf:/etc/openvpn/openvpn.conf ghcr.io/blinklabs-io/openvpn --config /etc/openvpn/openvpn.conf
1111
```
12+
13+
The image provides for the ability to provide a custom startup script. It looks for a user script at `/usr/local/bin/entrypoint-user.sh` by default,
14+
but the location can be overridden with the `USER_STARTUP_SCRIPT` environment variable

bin/entrypoint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
CONFIG_DIR=/etc/openvpn
44

5+
USER_STARTUP_SCRIPT=${USER_STARTUP_SCRIPT:-/usr/local/bin/entrypoint-user.sh}
6+
57
ENABLE_NAT=${ENABLE_NAT:-1}
68
NAT_SOURCE=${NAT_SOURCE:-10.8.0.0/24}
79
NAT_DEVICE=${NAT_DEVICE:-eth0}
@@ -16,4 +18,10 @@ if [[ $ENABLE_NAT = 1 ]]; then
1618
iptables -t nat -A POSTROUTING -s ${NAT_SOURCE} -o ${NAT_DEVICE} -j MASQUERADE
1719
fi
1820

21+
# Execute user startup script if it exists
22+
if [[ -e ${USER_STARTUP_SCRIPT} ]]; then
23+
chmod a+x ${USER_STARTUP_SCRIPT}
24+
${USER_STARTUP_SCRIPT}
25+
fi
26+
1927
exec openvpn --config ${CONFIG_DIR}/openvpn.conf --cd ${CONFIG_DIR} $@

0 commit comments

Comments
 (0)