Created
September 15, 2013 18:14
-
-
Save alukach/6573103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rm /tmp/hma.sh | |
cat <<INSTALL > /tmp/hma.sh | |
#!/bin/sh | |
cd /tmp | |
mkdir hma | |
cd hma | |
cat <<EOF > hma.conf | |
remote 173.208.32.98 53 | |
client | |
dev tun | |
proto udp | |
script-security 2 | |
resolv-retry infinite | |
nobind | |
persist-key | |
persist-tun | |
tun-mtu 1500 | |
tun-mtu-extra 32 | |
mssfix 1450 | |
ca /tmp/hma/ca.crt | |
cert /tmp/hma/cl.crt | |
ns-cert-type server | |
key /tmp/hma/cl.key | |
auth-user-pass /tmp/hma/user.txt | |
log /tmp/hma/hma.log | |
verb 2 | |
management 127.0.0.1 5001 | |
EOF | |
cat <<"EOF" > user.txt | |
INSTALL | |
if [ -f /tmp/hma.txt ]; then | |
b64=`cat /tmp/hma.txt` | |
echo "begin-base64 644 -" > /tmp/hma.txt | |
echo "$b64" >> /tmp/hma.txt | |
uudecode < /tmp/hma.txt >> /tmp/hma.sh | |
echo "" >> /tmp/hma.sh | |
rm /tmp/hma.txt | |
else | |
echo "/tmp/hma.txt: Not found: HMA-WRT Installation Failed" | |
fi | |
cat <<INSTALL >> /tmp/hma.sh | |
EOF | |
chmod 600 user.txt | |
cat <<EOF > ca.crt | |
-----BEGIN CERTIFICATE----- | |
CERT HERE | |
-----END CERTIFICATE----- | |
EOF | |
cat <<EOF >cl.crt | |
-----BEGIN CERTIFICATE----- | |
CERT HERE | |
-----END CERTIFICATE----- | |
EOF | |
cat <<EOF >cl.key | |
-----BEGIN RSA PRIVATE KEY----- | |
KEY HERE | |
-----END RSA PRIVATE KEY----- | |
EOF | |
chmod 600 cl.key | |
cat <<EOF > up.sh | |
#!/bin/sh | |
iptables -A POSTROUTING -t nat -o tun0 -j MASQUERADE | |
EOF | |
chmod 755 up.sh | |
cat <<EOF > dn.sh | |
#!/bin/sh | |
iptables -D POSTROUTING -t nat -o tun0 -j MASQUERADE | |
/tmp/hma/vpn.sh & | |
EOF | |
chmod 755 dn.sh | |
cat <<EOF > vpn.sh | |
#!/bin/sh | |
openvpn --config /tmp/hma/hma.conf --route-up /tmp/hma/up.sh --down /tmp/hma/dn.sh --daemon 2>&1 >> /tmp/hma/hma.log | |
EOF | |
chmod 755 vpn.sh | |
while [ \`date +%Y\` -lt 2013 ]; do | |
sleep 5 | |
done | |
sleep 2 | |
while ! ps|grep openvpn >/dev/null ; do | |
/tmp/hma/vpn.sh & | |
sleep 30 | |
done | |
INSTALL | |
nvram set hma="`cat /tmp/hma.sh`" | |
nvram set rc_startup="nvram get hma > /tmp/hma.sh; chmod 755 /tmp/hma.sh; /tmp/hma.sh; # Installed on 2013-09-15 10:58:25 #" | |
echo "Saving startup sequence" | |
nvram commit | |
echo "NVRAM saved" | |
cat <<BANNER | |
------------------------------------------ | |
| Congratulations! | | |
| HMA WRT Installed | | |
| | | |
| Please now reboot your router. | | |
| | | |
------------------------------------------ | |
BANNER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Backup of HMA's WRT OpenVPN setup script. Executed with:
More info:
http://wiki.hidemyass.com/DD-WRT_OpenVPN_Setup
https://vpn.hidemyass.com/vpncontrol/myaccounts/wrt