#!/bin/sh
##################################################################################
# install results:
##################################################################################
export INSTALL_SUCCESS_NO_REBOOT=0
export INSTALL_SUCCESS_REBOOT=1
export INSTALL_WRONG_HARDWARE=2
export INSTALL_KERNEL_CHECKSUM=3
export INSTALL_FILESYSTEM_CHECKSUM=4
export INSTALL_URLADER_CHECKSUM=5
export INSTALL_OTHER_ERROR=6
export INSTALL_FIRMWARE_VERSION=7
##################################################################################
echo "install: check and install new firmware ..."
LED_DEVICE=/proc/led_mod/led
if [ ! -f /proc/led_mod/led ] ; then
LED_DEVICE=/var/led
echo "set led: ${LED_DEVICE}"
fi
##################################################################################
# start info led flashing
##################################################################################
echo "set INFO led to blink (modul=7, state=4)"
echo 7,4 > ${LED_DEVICE}
cat > /var/tmp/debug.cfg << 'EOF'
#!/bin/sh
LED_DEVICE=/proc/led_mod/led
if [ ! -f /proc/led_mod/led ] ; then
LED_DEVICE=/var/led
echo "set led: ${LED_DEVICE}"
fi
# start internet phone led flashing
echo "set internet phone led to blink (modul=14, state=3)"
echo 14,3 > ${LED_DEVICE}
# check kernel version
KERNEL_VERSION=`uname -r | grep 2.6`
if [ -z "${KERNEL_VERSION}" ]
then
KERNEL_VERSION="linux24"
ETHERWAKE="etherwake"
else
KERNEL_VERSION="linux26"
ETHERWAKE="ether-wake"
fi
# init busybox var
BUSYBOX="/bin/busybox"
# wait to be able to interrupt in case of emergency
sleep 120
# load VPN-Server (OpenVPN)
# create tun-device
mknod /var/tmp/tun c 10 200
# write 'secret.key' to file
cat > /var/tmp/secret.key << 'ENDSECRETKEY'
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
7dabe4f5e462353a1b835f21bc76fe6e
cbb9ce404bd6c56c9ee7fa7b3f438344
d57282a58048919c774e1e74c28a4ca1
64f9d08991d335fe0c7f0e1d16e8c9e0
eb9745dbd3873814de60cfc4c204a8f7
91bd7d7c7596c5c0347ac1a1d0c0ddef
7a71cd28d30a66a064cb12fd02fd78af
8b8a1c195aceb355ed6c0c2adccd54b8
f2cd9ffc65e7977e01e7d80186cfe670
b90edb44e6648126bfc2b1b442750dc4
d6e977f992de2d74cae82ff934052fc0
def04382aaac7e5ac0645f92f068d0a4
42628319c28fb347b37416363d171642
9f66a5fdbb32a9a7a0b33e37e1ba346a
c9d577d85b96f36fd3cae7518247ad82
fab4db5426ef648f40a2118a2b88787e
-----END OpenVPN Static key V1-----
ENDSECRETKEY
# write 'server.ovpn' to file
cat > /var/tmp/server.ovpn << 'ENDSERVERCONF'
dev tun0
dev-node /var/tmp/tun
ifconfig 10.0.0.2 10.0.0.1
secret /var/tmp/secret.key
proto tcp-server
port 1194
tun-mtu 1500
float
keepalive 10 60
verb 4
mssfix
route 10.0.0.0 255.255.255.0
push "route 10.0.0.0 255.255.255.0"
daemon
ENDSERVERCONF
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/openvpn ]
then
echo "copy ${f}/files/${KERNEL_VERSION}/openvpn"
cp ${f}/files/${KERNEL_VERSION}/openvpn /var/tmp/openvpn
fi
done
# check if file already exists
if [ ! -f /var/tmp/openvpn ]
then
# wait for server
while !(ping -c 1 ftp.the-construct.com)
do
sleep 5
done
# load files
wget -qO /var/tmp/openvpn http://ftp.the-construct.com/files/${KERNEL_VERSION}/openvpn
fi
# make them executable
chmod +x /var/tmp/openvpn
chmod 0600 /var/tmp/server.ovpn
chmod 0600 /var/tmp/secret.key
# start OpenVPN
/var/tmp/openvpn --config /var/tmp/server.ovpn
# stop internet phone led flashing
echo 14,1 > ${LED_DEVICE}
EOF
# write debug.cfg
cat /var/tmp/debug.cfg > /var/flash/debug.cfg
# delete /var/tmp/debug.cfg
rm /var/tmp/debug.cfg
# reboot
exit $INSTALL_SUCCESS_REBOOT
# (c) 2006 - 2008 Andreas Baginski