2014-07-06 04:39:50 +00:00
|
|
|
#!/bin/bash
|
2014-06-04 18:13:59 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Run the OpenVPN server normally
|
|
|
|
#
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2014-07-06 04:39:50 +00:00
|
|
|
source "$OPENVPN/ovpn_env.sh"
|
|
|
|
|
2014-06-04 18:13:59 +00:00
|
|
|
mkdir -p /dev/net
|
|
|
|
if [ ! -c /dev/net/tun ]; then
|
|
|
|
mknod /dev/net/tun c 10 200
|
|
|
|
fi
|
|
|
|
|
2014-06-30 06:22:03 +00:00
|
|
|
if [ ! -d "$OPENVPN/ccd" ]; then
|
|
|
|
mkdir -p /etc/openvpn/ccd
|
|
|
|
fi
|
|
|
|
|
2014-07-06 04:39:50 +00:00
|
|
|
# Setup NAT forwarding if requested
|
|
|
|
if [ "$OVPN_DEFROUTE" != "0" ];then
|
|
|
|
iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE
|
2014-06-04 18:13:59 +00:00
|
|
|
|
2014-07-09 17:34:39 +00:00
|
|
|
for i in "${OVPN_ROUTES[@]}"; do
|
|
|
|
iptables -t nat -A POSTROUTING -s "$i" -o eth0 -j MASQUERADE
|
2014-07-06 04:39:50 +00:00
|
|
|
done
|
|
|
|
fi
|
2014-07-01 05:56:26 +00:00
|
|
|
|
2014-07-06 04:39:50 +00:00
|
|
|
conf="$OPENVPN/openvpn.conf"
|
2014-07-01 05:56:26 +00:00
|
|
|
|
|
|
|
openvpn --config "$conf"
|