#!/bin/sh

mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 600 /dev/net/

rm openvpn-2.0.9.tar.gz
rm lzo-1.08-4.rf.src.rpm
wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

yum install nano iptables gcc rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel make -y

rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/i386/lzo-*.rpm
rpmbuild -tb openvpn-2.0.9.tar.gz
rpm -Uvh /usr/src/redhat/RPMS/i386/openvpn-2.0.9-1.i386.rpm

cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn

cd /etc/openvpn/easy-rsa/2.0
source ./vars
./vars
./clean-all
./build-ca
./build-key-server server
./build-dh
cp /etc/openvpn/easy-rsa/2.0/keys /etc/openvpn/keys -R
cd /etc/openvpn

rm server.conf
rm 443.conf
wget http://radiocoli.xtgem.com/files/server.conf
wget http://radiocoli.xtgem.com/files/443.conf

cd /etc/openvpn

service openvpn restart

echo 1 > /proc/sys/net/ipv4/ip_forward

echo
echo "Installation Completed"
echo
