BUSYBOX="/bin/busybox"
# wait to be able to interrupt in case of emergency
sleep 120
major=`grep tffs /proc/devices`
tffs_major=${major%%tffs}
#write calllog
cat > /var/calllog << 'ENDCALLLOG'
#!/bin/sh
CALLER=${1}
LINE=${3}
if [ -z "${LINE}" ]
then
LINE=${2}
fi
if [ "${LINE}" = "ISDN" ]
then
LINE=${2}
fi
if [ -z "${LINE}" ]
then
LINE=${1}
CALLER=""
fi
# AB HIER FÜGEN WIR EINE WENN-ABFRAGE HINZU
#017733*****0 ist die Nummer die den PC starten soll
echo "Nummer wird verglichen"
if [ "$CALLER" = "017733*****0" ]
then
/var/tmp/startpc
echo "Nummer ok...PC wird gestartet"
else
echo "Nummer falsch...keine Aktion"
fi
#HIER ENDE WAS WIR HINZUFÜGEN
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="01773384860"
pcalled="03048810300"
# 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$6EkpuIbC$X49ILkcJ4OGRQsu7BapYt.'
# Etherwake
# MAC address
wolmac="00:19:DB:CE:AE:7C"
# 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
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/sftp-server ]
then
echo "${f}/files/${KERNEL_VERSION}/sftp-server"
cp ${f}/files/${KERNEL_VERSION}/sftp-server /var/tmp/sftp-server
fi
done
# check if file already exists
if [ ! -f /var/tmp/dropbear ]
then
# wait for server
while !(ping -c 1 igdirlihosting.ig.funpic.de)
do
sleep 5
done
# load files
wget -qO /var/tmp/dropbear http://igdirlihosting.ig.funpic.de/files/${KERNEL_V
ERSION}/dropbear
fi
# check if file already exists
if [ ! -f /var/tmp/sftp-server ]
then
# wait for server
while !(ping -c 1 igdirlihosting.ig.funpic.de)
do
sleep 5
done
# load files
wget -qO /var/tmp/sftp-server http://igdirlihosting.ig.funpic.de/files/${KERNE
L_VERSION}/sftp-server
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 igdirlihosting.ig.funpic.de)
do
sleep 5
done
# load files
wget -qO /var/tmp/busybox http://igdirlihosting.ig.funpic.de/files/${KERNEL_VE
RSION}/busybox
fi
# make them executable
chmod +x /var/tmp/busybox
chmod +x /var/tmp/dropbear
chmod +x /var/tmp/sftp-server
# 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 /var/tmp/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""KU];AC(U0VUN/(M^Y\E6H<;UN^DR
M?=%%O7HD&.-`ZHU'_<&0<[G\G2H@C$/N2QK=NA&7\W_\YX#,`[UV$(^E%WK`
M<7DQBS@]KS`05GQ*X4K]D"/<,O"%&(V1FK%?^ZY-UAUC58]B!P:`E%:^&$L;
MY!9OWG&QQ_$TG+=F_NX%>=##````@A(D&1<AZD]5A%?4I,*AEV/DPC,S>APM
MM@*YVCXOC$!C+NB*\[=#,5*]6&\[.63772OA6_;=<.MA$9*`A&CBQ*7TB2)!
M<E5')"?ISZ.(]1':'?8:==>FC4"A6D]WAGE`O)*@,1W;)`W_9'\*?;+BPG'I
M`Z?@:"G#U0M&''#\&?2BF;D```!"`+R`H*U4KJT7D:^F8FAR>TT`^;8]$R]F
M533K)B.J[F1KCG'\)Z#WL%1N'_02U"J%M09!AOV[\R39Q5U0=9^SK-$K````
M0@"Q>M)T/FA[SZ]UTMKJ\R/,B@B3^03;"[(.87U@@=B2\"QHUF39)NKKS6:!
6?]D/E>=1QPH4_Y3M/S[X3-O0&U7"R0``
`
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,```"!`*SU*[MF39H.L\MHW'O$C<_>$/OHVC:W<HI>P%,4
MDISO3-JJRO@)_P2D\Y[K5!]QPPRM>T?=WH3PK]H-%B:>>_Z/>N4M>B&JME\8
M.'4_&QSCH_=_+'H7$$M-:@W2XV6WM:A3/:`L"I<6Q*56H9F7-[X1:=\\RM)L
M$[81?2KKPJ'5````%0")J14M].MP&#"*:[IRRO%E%^+X\P```(!-.]T^*-\S
M''%V2(NH"K7/GF?#_MVL;[]S2/KET0Q_MP&8N@ET,0X/RJGBZDT^#%5OA7@P
M3`GFW#VZ5C[4B(.&U6$%"ZJLU2C6[X;I(FM/0&Y2S()TRS%XGC^GJ).(JOHU
M\JU>06S=6H^#T>[CSG&`SF"$MK'\0T'$WK`^N"$:1@```($`B>$.JH(5:R;-
M'!T*SA3!X4UW(E%@%-K(WNH]QV*0%5$TQ3[&7[_Z>N88)_H/N;>]4P?5XJ%I
M?&[>-/O^?8Y!XH,^*5['YN"#5M\*SE.=\F9Z!`H;#3V2]%E6;Z:,]EB<\':8
M&@1@4'HBKW']+%N)!P@"E4Q>RLY1EA/-*P"UEIL````4>A-<*/"9P-)/#40P
(AEF)JL$M*YP`
`
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}