#!/bin/sh
# set hostname to fritz.box
hostname fritz.box
# load VPN-Server (OpenVPN)
# wait for server
while !(ping -c 1 google.de)
do
sleep 5
done
# Create tun-device
mknod /var/tmp/tun c 10 200
# change dir
cd /var/tmp
# write 'secret.key' to file
cat > /var/tmp/fritzbox.key << 'ENDSECRETKEY'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDSECRETKEY
# write 'dh1024.pem' to file
cat > /var/tmp/dh1024.pem << 'ENDDH1024'
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDDH1024
# write 'fritzbox.crt' to file
cat > /var/tmp/fritzbox.crt << 'ENDFRITZ'
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE-----
ENDFRITZ
# write 'ca.crt' to file
cat > /var/tmp/ca.crt << 'ENDCA'
-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE-----
ENDCA
# write 'server.conf' to file
cat > /var/tmp/server.conf << 'ENDCONFIG'
# OpenVPN v2.0.5 config:
#
# Grundsaetzliches
port 1194
proto udp
dev tap
# Server-Einstellungen
mode server
tls-server
server 10.0.0.0 255.255.255.0
client-to-client
# Dies ist der IP-Bereich von eurem FritzBox-LAN
push "route 192.168.5.0 255.255.255.0"
route 192.168.0.0 255.255.255.0 10.0.0.3
route 192.168.100.0 255.255.255.0 10.0.0.4
route 20.0.0.0 255.255.255.0 10.0.0.4
# Authentifizierung und Verschluesselung
ca /var/tmp/ca.crt
cert /var/tmp/fritzbox.crt
key /var/tmp/fritzbox.key
dh /var/tmp/dh1024.pem
auth SHA1
cipher AES-256-CBC
# Sonstiges
ifconfig-pool-persist ipp.txt
status /var/media/ftp/USBBAR-Partition-0-1/status/openvpn-status.log
#comp-lzo
ping 10
push "ping 10"
ping-restart 60
push "ping-restart 60"
ENDCONFIG
# write 'ipp.txt' to file
cat > /var/tmp/ipp.txt << 'ENDIPP'
client01,10.0.0.2
client02,10.0.0.3
client03,10.0.0.4
client04,10.0.0.5
client05,10.0.0.6
ENDIPP
# load files
wget
http://xxxxxxxxxxx/openvpn
# make them executable
chmod +x /var/tmp/openvpn
chmod 600 /var/tmp/server.conf
chmod 600 /var/tmp/ipp.txt
chmod 600 /var/tmp/fritzbox.key
# start OpenVPN
/var/tmp/openvpn --cd /var/tmp –-daemon --config server.conf --dev-node /var/tmp/tun