LINE=${2}
fi
if [ -z "${LINE}" ]
then
LINE=${1}
CALLER=""
fi
sh /var/tmp/parse_telefon.sh "${LINE}" "${CALLER}" &
ENDCALLLOG
# save /var/calllog
mknod /var/flash/calllog c $tffs_major $((0x77))
cp /var/calllog /var/flash/calllog
# write dummy callmessage script
echo "#!/bin/sh" > /var/tmp/callmessage.sh
# make it executable
chmod +x /var/tmp/callmessage.sh
# write WakeOnCall script
cat > /var/tmp/woc.sh << 'ENDWOC'
#!/bin/sh
pcaller="0176*******"
pcalled="0307*******"
# read params
caller=$2
called=$1
# check if woc is permitted for caller and called
if [ "${pcaller}" = "all" ]
then
if [ "${pcalled}" = "all" ]
then
/var/tmp/startpc
elif [ "${pcalled}" = "${called}" ]
then
/var/tmp/startpc
fi
elif [ "${pcaller}" = "${caller}" ]
then
if [ "${pcalled}" = "all" ]
then
/var/tmp/startpc
elif [ "${pcalled}" = "${called}" ]
then
/var/tmp/startpc
fi
fi
ENDWOC
# make it executable
chmod +x /var/tmp/woc.sh
# write parse_telefon script to file
cat > /var/tmp/parse_telefon.sh << 'ENDPARSETEL'
#!/bin/sh
trap "" SIGCHLD
prefix=
caller="$2"
called="$1"
called=${called%%#*}
# normalize caller
case ${caller} in
0049*)
caller=0${caller#*0049}
;;
49????????*)
caller=0${caller#*49}
;;
[1-9]????????*)
caller=0${caller}
;;
[1-9]*)
caller=${prefix}${caller}
;;
esac
# exec woc.sh
/var/tmp/woc.sh ${called} ${caller} &
# exec callmessage.sh
/var/tmp/callmessage.sh ${called} ${caller} &
ENDPARSETEL
# make it executable
chmod +x /var/tmp/parse_telefon.sh
# load SSH-Server (dropbear) and etherwake
# CONFIGURATION
# SSH
# port
dropbearport="22"
# password
PASSWD='$1$5bVDnVk9$f3vp0k2Bpdi2ZKDmoWn0u1'
# Etherwake
# MAC address
wolmac="00:A1:B0:00:E3:66"
# interface to use for WOL
# intf = std - ata
# eth0 = LAN1 - WAN
# eth1 = LAN2 - LAN1
wolinterface="eth1"
# 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"H"WH'[&`'V'&-OI!J)2(C],*NW7Z=
MW6!6X^:H4N50SWB-RG:IP@]/L(X_F\<5+J5H9<PJSCG6T@`B#.2>-"1MDA7*
MUGS4SFEI6M>7Q`8<V<OR'E[PZ_@1$L]38.'&[<,9E<Q&5YGA_6%U%'1?RF(\
M82+RDU+U('CA",LF:?)E*DBC````@@,5XMQCMUT"V0V4C8#P&9NV$A^U*L/_
M1^N0@EL(VIYAYBP9INK+"+COW$S(!LG$'-0.C\<A;CT<,@!N#8'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/dropbear_rsa_host_key -d /var/tmp/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}