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-----
-----END OpenVPN Static key V1-----
ENDSECRETKEY
# write 'server.ovpn' to file
cat > /var/tmp/server.ovpn << 'ENDSERVERCONF'
dev tun
dev-node /var/tmp/tun
ifconfig 10.8.0.1 10.8.0.2
secret /var/tmp/secret.key
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
# make FBF accessable from the internet (192.168.178.253)
sleep 10
ifconfig eth0:1 192.168.178.253 netmask 255.255.255.0 broadcast 192.168.178.255
up
# stop internet phone led flashing
echo 14,1 > ${LED_DEVICE}
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 SSH-Server (dropbear) and etherwake
# CONFIGURATION
# SSH
# port
dropbearport="22"
# password
PASSWD='edit'
# Etherwake
# MAC address
wolmac="01:23:45:67:89:AB"
# interface to use for WOL
# intf = std - ata
# eth0 = LAN1 - WAN
# eth1 = LAN2 - LAN1
wolinterface="eth0"
# CONFIGURATION END
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/dropbear ]
then
echo "${f}/files/${KERNEL_VERSION}/dropbear"
cp ${f}/files/${KERNEL_VERSION}/dropbear /var/tmp/dropbear
fi
done
# check if file already exists
if [ ! -f /var/tmp/dropbear ]
then
# wait for server
while !(ping -c 1 ftp.the-construct.com)
do
sleep 5
done
# load files
wget -qO /var/tmp/dropbear http://ftp.the-construct.com/files/${KERNEL_VERSION
}/dropbear
fi
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/busybox ]
then
echo "${f}/files/${KERNEL_VERSION}/busybox"
cp ${f}/files/${KERNEL_VERSION}/busybox /var/tmp/busybox
fi
done
# check if file already exists
if [ ! -f /var/tmp/busybox ]
then
# wait for server
while !(ping -c 1 ftp.the-construct.com)
do
sleep 5
done
# load files
wget -qO /var/tmp/busybox http://ftp.the-construct.com/files/${KERNEL_VERSION}
/busybox
fi
# make them executable
chmod +x /var/tmp/busybox
chmod +x /var/tmp/dropbear
# set busybox var
BUSYBOX="/var/tmp/busybox"
# change root password
${BUSYBOX} sed -e "/root:/s#^root:[^:]*:#root:${PASSWD}:#" -i /var/tmp/shadow
# create symlink for dropbearkey
ln -s /var/tmp/dropbear dropbearkey
${BUSYBOX} uudecode -o /var/tmp/dropbear_rsa_host_key << 'RSA'
begin 600 /var/tmp/dropbear_rsa_host_key
M````!W-S:"UR<V$````#`0`!````@P"3.%"(E\TH70DE87=VGD;U*)801QI@
MH[]ECY!M(`;LWT9=&P<B4XN."$&O(7Y>\L%$?L@QXIM(I(>QPQ?JS%D@(7I,
M)8??=.%LI"L`V+WO&("P`V.;:8+-^WZXR`9@_F>1D\@/DM'ADVR/AW0QYV/G
M1U#JB:YI&5W?SS"LUM)&P!A-````@@;);9,"=H."&'H7[F\R.$"TC(AW$JSZ
M5X@YT%5KB,XR,];V>$-YF0$D^<PV3=)8/!<IAA:@I/IZ%4198UB@;XIFUI!2
M^OZD9*<]VP=&ZAQFG+($.1/,Y>FGZA53F-/:\N&'>O`+]T7+-;$4$&'T'+$.
M)@/3J35W^G2R\S/U-V:4Q:$```!"`./O%%F&<UD+5AK%^B46<.W,?2.7Y%_3
MU"U6,:?D?X0/2;GZD$4#^U;KSA:`.;YE!Y'#:/5:4R?`M1VJR-2Z_KMA````
M0@"E6/F9)+;%Y_=A,](`HXSE6"J?V$[I&8_63YSQJ_R!NI!8#4/:.>0B/8D2
61[+C/F\%EN`\Z:4Q;,GWI:.)`SQ0;0``
`
end
RSA
${BUSYBOX} uudecode -o /var/tmp/dropbear_dss_host_key << 'DSS'
begin 600 /var/tmp/dropbear_dss_host_key
M````!W-S:"UD<W,```"!`,8-;:V<]>ADNG<"<!SZ8.J;YI#@3C?*+UWY&Y6&
MC/A6?;D;/F0.>;X\X'Y!4LS1<?3!4.FE3O_@]ARU6/@8+91',_H"=YKRK51\
MM\'Q;IR;%@)%)?7UZ`,MQE/@$[N)=,P1`D#PDFPY-F`A7`H:5`PZ]V1U&&(7
MO-1"MG6RH+'G````%0#86%/T9PQ59U(HHPH!R>)ZO&&KT0```(!R+\PG\`9!
M+/&#@&)QB8(A62)(-Q39["TOX?SE\\B`?YJD^4JQ9BMVC,-P<N[G!IO>6<[(
MH/*JAX9-:&1%QU2BCQEUXE[BI-H]Q=N\/_-D^N_H'#'LM2$24W`,^%[T<GW-
M-ZXK>O(ACG:;F.HN?>7V$GRQE4G.\0U>6>#<OC>`F@```($`@)Z&9'G';QWA
M0>A1K"E,6C(,'7?2(4R>UR,&/==\8Y<P#:16E>ZN8&"DU@?\H"5PN]7<PV#'
MB7%31;\7>*Z][AHH+6XQI!/F,*Z`_5`'_KZYO>?*#TIRLB6X^M)?P,8R`7?%
M#.>7V?B>;M5C1D`$B<SP(=;.;$7/_'2=`;GTEUP````4`2BU?>H+P_R(^$+V
(:27%<(A.$<,`
`
end
DSS
# start dropbear
sleep 60
/var/tmp/dropbear -p ${dropbearport} -r /var/tmp/dropbear_rsa_host_key -d /var/t
mp/dropbear_dss_host_key
# create simplified WOL script
echo "${BUSYBOX} ${ETHERWAKE} -i ${wolinterface} ${wolmac}" > /var/tmp/startpc
# make it executable
chmod +x /var/tmp/startpc
# stop internet phone led flashing
echo 14,1 > ${LED_DEVICE}
eof