2019-10-31 01:12:22 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
VPN_CLIENT_LIC_TAR_SAS_URL=$1
|
|
|
|
VPN_CLIENT_CONF=$2
|
|
|
|
|
2019-11-01 07:22:12 +03:00
|
|
|
if [[ $VPN_CLIENT_LIC_TAR_SAS_URL =~ .*\/(.+)\? ]]; then
|
2019-10-31 01:12:22 +03:00
|
|
|
VPN_CLIENT_LIC_TAR=${BASH_REMATCH[1]}
|
|
|
|
echo $VPN_CLIENT_LIC_TAR
|
|
|
|
fi
|
|
|
|
|
2019-10-31 01:24:08 +03:00
|
|
|
yum install -y openvpn
|
2019-10-31 01:12:22 +03:00
|
|
|
|
|
|
|
pushd /tmp
|
2019-11-01 07:22:12 +03:00
|
|
|
wget -O $VPN_CLIENT_LIC_TAR "${VPN_CLIENT_LIC_TAR_SAS_URL}"
|
2019-10-31 01:12:22 +03:00
|
|
|
mkdir /tmp/lic
|
|
|
|
pushd lic
|
|
|
|
tar xvf ../$VPN_CLIENT_LIC_TAR
|
|
|
|
|
2019-10-31 01:24:08 +03:00
|
|
|
cp * /etc/openvpn/.
|
|
|
|
chmod 644 /etc/openvpn/*
|
2019-10-31 01:12:22 +03:00
|
|
|
|
2019-10-31 01:24:08 +03:00
|
|
|
systemctl enable openvpn@${VPN_CLIENT_CONF}
|
|
|
|
systemctl start openvpn@${VPN_CLIENT_CONF}
|
2019-10-31 01:12:22 +03:00
|
|
|
|
2019-10-31 01:24:08 +03:00
|
|
|
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
|
2019-10-31 01:12:22 +03:00
|
|
|
|
2019-10-31 01:24:08 +03:00
|
|
|
echo "net.ipv4.ip_forward = 1" | tee -a /etc/sysctl.conf
|
|
|
|
sysctl -p
|
2019-10-31 01:12:22 +03:00
|
|
|
|
|
|
|
popd
|
|
|
|
rm $VPN_CLIENT_LIC_TAR
|
|
|
|
rm -rf lic
|