container-openvpn/bin/ovpn_run
Kyle Manna b9cc5b347a genconfig: Convert OVPN_ROUTES to array
* Convert to an array to simplify the code.
* This breaks running `ovpn_genconfig` multiple times with the same
  route argument as the array will just grow.  This needs to be fixed in
  the future.
* Recommended way to work around this is to remove ovpn_env.sh.
2014-07-09 11:06:02 -07:00

32 lines
564 B
Bash
Executable File

#!/bin/bash
#
# Run the OpenVPN server normally
#
set -ex
source "$OPENVPN/ovpn_env.sh"
mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
fi
if [ ! -d "$OPENVPN/ccd" ]; then
mkdir -p /etc/openvpn/ccd
fi
# Setup NAT forwarding if requested
if [ "$OVPN_DEFROUTE" != "0" ];then
iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE
for i in "${OVPN_ROUTES[@]}"; do
iptables -t nat -A POSTROUTING -s "$i" -o eth0 -j MASQUERADE
done
fi
conf="$OPENVPN/openvpn.conf"
openvpn --config "$conf"