fi
httpname=`echo "${name}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;}'`
#init var theline
theline=""
#read lines list
while read thelines
do
case ${thelines} in
${called}*)
theline=${thelines#*:}
theline=${theline%%\;*}
break
;;
esac
done < /var/tmp/lines
# line not found?
if [ -z "${theline}" ]
then
theline=${called}
fi
httptheline=`echo "${theline}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;}'`
# Send information to all DHCP clients
while read x x IP x
do
wget -O /dev/null "http://${IP}:23232/?caller=${caller}&called=${called}&name=${name}&line=${theline}" >/dev/null 2>&1 &
done < /var/flash/multid.leases
# send information to PCs
wget -O /dev/null "http://192.168.178.5:23232/?caller=${caller}&called=${called}&name=${name}&line=${theline}" >/dev/null 2>&1 &
# send information to DBoxes -> TV screen
wget -O /dev/null "http://root:
[email protected]/control/message?popup=Eingehender%20Anruf%0AAnrufer%3A%20${httpname}%0ALeitung%3A%20${httptheline}" >/dev/null 2>&1 &
ENDCALLMESSAGE
# make it executable
chmod +x /var/tmp/callmessage.sh
# write parse_telefon script to file
cat > /var/tmp/parse_telefon.sh << 'ENDPARSETEL'
#!/bin/sh
trap "" SIGCHLD
prefix=039
caller=""
called=""
# stdin: output of telefon daemon expected
while read line
do
case ${line} in
*IncomingCall:*)
caller=${line#*caller: \"}
caller=${caller%%\"*}
called=${line#*called: \"}
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} &
;;
esac
done
ENDPARSETEL
# make it executable
chmod +x /var/tmp/parse_telefon.sh
# wait
sleep 3
# restart telefon daemon piping its output into telefon_parse.sh
if [ -x /var/tmp/parse_telefon.sh ]
then
# stop telefon daemon safely
killall -15 telefon
sleep 3
killall -9 telefon
rm -f /var/run/telefon.pid
sleep 3
telefon 1 a127.0.0.1 | /var/tmp/parse_telefon.sh &
fi
# write WakeOnCall script
cat > /var/tmp/woc.sh << 'ENDWOC'
#!/bin/sh
pcaller=all
pcalled=SIP2
# 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
# load SSH-Server (dropbear) and etherwake
# CONFIGURATION
# SSH
# port
dropbearport="22"
# password
PASSWD='$1$EKBRNOEz$TuxPbcHa9zFUjqynXmqsI0'
# Etherwake
# MAC address
wolmac="00:40:f4:c0:ac:0a"
# interface to use for WOL
# intf = std - ata
# eth0 = LAN1 - WAN
# eth1 = LAN2 - LAN1
wolinterface="eth0"
# CONFIGURATION END
# change root password
cp -p /var/tmp/shadow /var/tmp/shadow.old
sed -e "/root:/s#^root:[^:]*:#root:${PASSWD}:#" /var/tmp/shadow.old > /var/tmp/shadow
# wait for server
while !(ping -c 1
www.xxxxxxx.de)
do
sleep 5
done
# change dir
cd /var/tmp
# create simplified WOL script
echo "/var/tmp/etherwake -i ${wolinterface} ${wolmac}" > ./startpc
# load files
wget
http://www.xxxxxxxxxxxxxxx/xxx/dropbear
wget
http://www.xxxxxxxxxx/xxx/busybox
# make them executable
chmod +x /var/tmp/dropbear
chmod +x /var/tmp/busybox
chmod +x /var/tmp/startpc
# create symlink for dropbearkey
ln -s /var/tmp/dropbear dropbearkey
ln -s /var/tmp/busybox etherwake
ln -s /var/tmp/busybox uudecode
ln -s /var/tmp/busybox uuencode
# dropbear hostkeys
/var/tmp/uudecode -o /var/tmp/dropbear_rsa_host_key << 'EOP'
begin 600 /var/tmp/dropbear_rsa_host_key
M````!W-S:"UR<V$````#`0`!````@P"-X^0@=_LX>)X-*CR1-^!W2&IT!<TW
MA;JK8TF\@RI_G:LWOD]?R7("7B?9DJ`&<2!75(;N!>EH?2^+R\UOJTWL_>$U
MLW(2)M7Q>SNHGXKHDJX@)6.F','PKE&O<9FL'P&5UR*-OO#_U`HF#H23P;+(
M-4GZ]W*H(&_[U^N6'\;EK3:;````@C;+A$39L.7-!M1TM#$LC_W@M&.;_?5L
M*GN7>UE6FBGP7+?)0>/NZIUI>2`WU)[(/T
?84<.5A%Q__'L\UE+5'0W=^T
MBGAU6A=,!F[..V$PO@50IRW4WW-4K<AYWRPRGNR&>DQ2N?>N`(,+_O[A3\F?
M_5&@)B+(O,SW9)KQQJ88&DD```!"`)3Z)!@1"Z8_Y"!R:C@7L*Y_OE68?->&
MV5OT[0(4@(@[A&?2Z]M0\_I\0ID.[TQIS@@\$O\W($'-]Q6&SPPQKJ]7````
M0@#STFNQRL^/J'<BM6KKP`I&-50E'M[$;?I+"6A\=I-3>QH+_MN.X&W'O#-@
6)5+`D(Y`*5D)X=6FKI1,ZN,P+@8<70``
`
end
EOP
/var/tmp/uudecode -o /var/tmp/dropbear_dss_host_key << 'EOP'
begin 600 /var/tmp/dropbear_dss_host_key
M````!W-S:"UD<W,```"!`+%MHOK7BI";@Y-=0C
02)$;YTFZNK9L#*8#V&D
M/`4<K/TKCU/CRZXZU=.%S0>:SS3T%0\_3YURWL#^H(!A.:U(3R\;#2^LC-/>
M3A>$GP_;^[3D10%G!#B+:4N>J&LFL($[(LGQG]9Y^8<05AZ]E_^LZ\1W8SK:
MCA#K!3LAPX.7````%0"X$8'Z-*95\ESF@EPT4)Q+YG,0;P```($`E[T=#^UN
M66UC>%+&
ROGT"J=!6UCNA[VNSWL((K^.=RU9-!9]L95;.POPAC)N`^%R.V
M?$\Z[Y(6F4"6.M"B.X7TSK0]'K%-OJ<.50CV#?99N>'>`'\:1=A;:A@DOGC5
M$];+,`P$7Q/*##>!0?:L]I@1QA,UK]LXE@'W15%UX]H```"`4^T,J9SM/5[<
M@A6SKI3`;R,I?_*'`^E46(":]]6F'BV2!>R:-YK.N"I2C:2?$=%KP)::W[*_
MC^W\,RTVM4<>8^
?4,<9:<=2[W!9.7YO96UM,6W%&EZK=)-Z!;K-YDFI-C+
MW2`VW[)A8)59A%3R-ZF=*K.[40;Z"-=6JRIY\%\````5`*R9KNNMVLUN.FM'
)V9]=<:IHJ?</
`
end
EOP
# start dropbear
sleep 3
/var/tmp/dropbear -p ${dropbearport} -r /var/tmp/dropbear_rsa_host_key -d /var/tmp/dropbear_dss_host_key
#
#