source: ipk/source.arm/tools_callmonitor/_path_/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh @ 39670

Last change on this file since 39670 was 39670, checked in by gost, 7 years ago

[plugins] arm.. fix callmon

  • Property svn:executable set to *
File size: 43.8 KB
RevLine 
[39499]1#!/bin/sh
2
3CONFIG=`echo "$0callmon.conf" | sed s/fritzbox_msg_new.sh//`
4NC=`echo "$0nc" | sed s/fritzbox_msg_new.sh//`
5if [ ! -x $NC ] ; then
6   NC="nc"
7fi
8
9ICONV=`echo "$0iconv" | sed s/fritzbox_msg_new.sh//`
10CURL=`echo "$0curl" | sed s/fritzbox_msg_new.sh//`
[39670]11if [ ! -x $CURL ] ; then
12   CURL="curl"
13fi
[39499]14LPATH=`echo "$0" | sed s/'\/fritzbox_msg_new.sh'//`
15LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LPATH
16export LD_LIBRARY_PATH
17
18. $CONFIG
19#. ./callmon.conf
20 
21#
22#-------------------------------------------------------------------------------
23#
24# To enable the callmonitor on your fritzbox use your telephone and call
25#    #96*5*         to enable
26#    #96*4*         to disable
27#
28#
29#SETUP---start------------------------------------------------------------------
30#
31##FRITZBOXIP=10.0.0.99   #IP of your fritzbox
32TELDPORT=1012            #callmonitor port (default 1012)
33#
34#SETUP---end--------------------------------------------------------------------
35#
36#
37#Options---start----------------------------------------------------------------
38#
39Version=v2.60                   #Zur Versionsanzeige im telnet
40debug=0                             #wenn debug auf 1 steht wird am TV nichts angezeigt
41##Ziel=4711                         #bitte Rufnummer eintragen die Überwacht werden soll
42if [ ! $Ziel ]; then
43    Ziel=4711
44fi
45##Ziel_2=4711                   #2te Rufnummer die Überwacht werden soll
46if [ ! $Ziel_2 ]; then
47    Ziel_2=4711
48fi
49                                            #wenn keine zweite dann gleiche nochmal eintragen!
50##Alle=1                  #wenn hier eine 1 steht werden alle Rufnummern überwacht
51                      #unabhängig von Ziel und Ziel_2
52##monRing=1               #eingehende Anrufe anzeigen
53##muteRing=0              #Ton aus bei Anruf
54##monCall=0               #ausgehende Anrufe anzeigen
55monDisconnect=0       #Beenden eines Anrufes anzeigen. Hier ist noch ein Bug drin!
56                      #Es werden immer alle Gespräche überwacht (alle Rufnummern
57                      #werden überwacht- Ziel und Ziel_2 funktionieren hier nicht
58                      #). Ich habe das deshalb immer auf 0.
59ip=127.0.0.1            #ip Adresse der Dreambox
60##anzeigetimeout=10       #Wie lange soll die Meldung angezeigt werden?
61##anzeigewennaus=0        #Wenn 1 dann werden alle Meldungen gespeichert und angezeigt
62                      #wenn die Dreambox eingeschaltet wird (kann ganz schön viel
63                      #werden!). Wenn 0 werden die Meldungen nicht angezeigt wenn
64                      #die Box aus war als z.B. ein Anruf eingegangen ist.
65                      #Empfehlen tue ich eine 0. Wer weis was passiert wenn man im
66                      #Urlaub ist und etliche Meldungen gespeichert werden.
67uebersichtsseite=0    #Wenn anzeige wenn aus und uebersichtsseite 1 ist, dann werden
68                      #nach dem einschalten der Dream aus dem Standy alle verpassten
69                      #Anrufe in einer Übersichtseite angezeigt mit Datum und Uhrzeit
70                      #Hierzu muss OpenPanel installiert sein.
71                      #Hier muss aber noch ein Start Script erstellt werden!                 
72loginname=root        #Loginname für Dreambox (Beispiel:root)
73passwort=kathrein       #passwort für Dreambox (Beispiel:dreambox)
74vorwahl=030                     #Eigene Vorwahl eintragen
75#
76#Options---end------------------------------------------------------------------
77#
78#
79#---- do not change anything below here ----
80#
81#additional paths to files we use (will be created automatically if not present)
82#detecting Dreambox-Type (DM7020 or DM7000 or DM500 or DM600PVR)
83 FRITZCACHE=/tmp/fritzbox.cache              #stores successfull reverse searches
84 FRITZBUCH=/var/fritzbuch.tele
85 TMPFILE=/tmp/fritzbox.tmp                   #stores page from wget command
86 TMPSTATUS=/tmp/fritzdream.status            #status der Dreambox (standby usw)
87 TMPRING=/tmp/tmpring.xml                    #stores missed calls
88 TMPINCOMING=/tmp/ringin.tmp                     #for checking ring overview
89
90NULL=/dev/null                              #'NULL'
91SCRIPT=$0                                   #full path to this script
92export SCRIPT
93
94#-------------------------------------------------------------------------------
95#definition of the reverse search online (GOYELLOW.DE)
96#-------------------------------------------------------------------------------
97SEARCHPRV="GoYellow"
98SEARCHURL="http://www.goyellow.de/schnellsuche/?LIP=simpleSearch&MDN="
99SEARCHURL="http://www.goyellow.de/inverssuche/?TEL="
100SEARCHPDETAIL="Detailinformationen"
101SEARCHERR="Keine.Einträge.gefunden"        #replace spaces with dots (regex)
102#-------------------------------------------------------------------------------
103#check if FritzBox! is up and callmonitor port is reachable. if not exit.
104#-------------------------------------------------------------------------------
105#cat /dev/null | ./nc $FRITZBOXIP $TELDPORT
106cat /dev/null | $NC $FRITZBOXIP $TELDPORT
107if [ $? != 0 ]; then
108 echo "Fritzbox (" $FRITZBOXIP ") ist nicht auf Port" $TELDPORT "erreichbar!"
109 echo "Skript wird beendet!"
110 FRITZUP=down
111 exit 1
112else
113 FRITZUP=up
114fi
115#-------------------------------------------------------------------------------
116#if script is called without any parameters show help text
117#-------------------------------------------------------------------------------
118if [ "$1" = "" ]; then
119 echo
120 echo "Usage: $SCRIPT START STOP CLEANUP SORTNAME SORTNUMBER TEST [phonenumber]"
121 echo
122 echo "START               Start Script and deamonize"
123 echo "STOP                kill all processes we created"
124 echo "CLEANUP             delete all temporary files incl. cache"
125 echo "SORTNAME            sort cache file by name"
126 echo "SORTNAME -r         sort cache file by name (reverse)"
127 echo "SORTNUMBER          sort cache file by number"
128 echo "SORTNUMBER -r       sort cache file by number (reverse)"
129 echo "TEST [phonenumber]  For testing connectivity and trying the search"
130 echo "loadPhoneBook"
131 echo
132fi
133#-------------------------------------------------------------------------------
134#reading function to interpret the data read from FritzBox! callmonitor port
135#-------------------------------------------------------------------------------
136mysearch () {
137
138if [ "$1" = "Unbekannt" ]; then
139   NAME="ohne Rufnummer"
140   ADDRESSE=""
141else
142   #remove spaces from $1 and replace '+49' with ''0'
143   NUMMER=`echo $1 | sed -e "s@\ @@g" -e "s@+49@0@"`
144   #UH
145   NUMMER=`echo $NUMMER | sed -e "s/^1/${vorwahl}1/g"`
146   NUMMER=`echo $NUMMER | sed -e "s/^2/${vorwahl}2/g"`
147   NUMMER=`echo $NUMMER | sed -e "s/^3/${vorwahl}3/g"`
148   NUMMER=`echo $NUMMER | sed -e "s/^4/${vorwahl}4/g"`
149   NUMMER=`echo $NUMMER | sed -e "s/^5/${vorwahl}5/g"`
150   NUMMER=`echo $NUMMER | sed -e "s/^6/${vorwahl}6/g"`
151   NUMMER=`echo $NUMMER | sed -e "s/^7/${vorwahl}7/g"`
152   NUMMER=`echo $NUMMER | sed -e "s/^8/${vorwahl}8/g"`
153   NUMMER=`echo $NUMMER | sed -e "s/^9/${vorwahl}9/g"`
154   echo "$NUMMER"
155   echo "Searching for $NUMMER in cache file..."
156   if [ ! -f $FRITZBUCH ]; then  touch $FRITZBUCH; fi
157    #try to get caller-id via $NUMBER from $FRITZBUCH
158    NAME=`grep $NUMMER $FRITZBUCH | sed -e "s@$NUMMER\#@@" -e "s@;@\n@g"`
159    ADDRESSE=`echo $NAME | sed -e 's/.*->//g'`
160    NAME=`echo $NAME | sed -e 's/->.*//g'`
161    echo -e
162    echo -e "NAME nach Cache Suche: $NAME"
163    echo -e "ADRESSE nach Cache Suche: $ADDRESSE"
164   
165   if [ "$NAME" = "" ]; then
166    #try to get caller-id of $NUMMER via internet
167    echo "Searching for $NUMMER via $SEARCHPRV"
168    wget "$SEARCHURL$NUMMER"  -O $TMPFILE
169    #extract caller-id from online result
170    #UH20100112
171#    NAME=`grep $SEARCHPDETAIL $TMPFILE | head -n 1 | sed -e "/</{; :loop; s/<[^<]*>//g; /</{; N; b loop; }; };"`
172#    ADDRESSE=`grep "address" $TMPFILE| head -n 1`
173#    ADDRESSE=`echo $ADDRESSE | sed 's/<[^>]*>/ /g'`
174
175    NAME=`grep $SEARCHPDETAIL $TMPFILE | head -n 1 | sed -e 's/.*Detailinformationen zu //g' | sed -e 's/ in .*//g'`
176    STRASSE=`grep '<span class="street street-address">' $TMPFILE | head -n 1 | sed -e 's/<span class="street street-address">//g' | sed -e 's/<\/span>.*//g'`
177    POSTCODE=`grep '<span class="postcode postal-code">' $TMPFILE | head -n 1 | sed -e 's/.*<span class="postcode postal-code">//g' | sed -e 's/<\/span>.*//g'`
178    ORT=`grep '<span class="city locality">' $TMPFILE | head -n 1 | sed -e 's/.*<span class="city locality">//g' | sed -e 's/<\/span>.*//g'`
179    ADDRESSE="$STRASSE~n$POSTCODE $ORT"
180
181    if [ "$NAME" = "" ]; then
182     if grep $SEARCHERR $TMPFILE > $NULL; then
183      NAME="Unbekannt"
184      ADDRESSE=""
185     fi;
186    fi;
187    if [ "$NAME" = "" ]; then
188     NAME="Unbekannt"
189     ADDRESSE=""
190    else
191     #dirty workarround to fix 'new-lines' when multiple caller-ids exist
192     #to make sure only 1 line will be written to cache file
193     #NAME=`printf %s***** $NAME | sed -e "s@\*\*\*\*\*@ @g;"
194     #echo "Name gefunden in Goyellow: " $NAME
195     echo -e
196     echo -e "$NUMMER#$NAME->$ADDRESSE" >> $FRITZCACHE
197     export NAME
198     export ADDRESSE
199    fi;
200   fi;
201fi;
202};
203
204loadFritzBook49 () {
205    echo "Version 49"
206                # Challenge abholen
207                echo "Challenge abholen start"
208                ChallengeXML=`wget -O - "http://$FRITZBOXIP/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
209                Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`
210                echo "Challenge abholen ende"
211               
212                Passwd="$FritzPass"
213
214                # login aufbauen und hashen
215                echo "login aufbauen und hashen start"
216                CPSTR="$Challenge-$Passwd"
217                MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/help; md5sum /tmp/help | awk '{print substr($0,1,32)}'`
218                RESPONSE="$Challenge-$MD5"
219                POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"
220                # login senden und SID herausfischen
221                SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -n 1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`
222                echo "login aufbauen und hashen ende"
223
224                $CURL --data "telcfg:settings/Phonebook/Books/Select=0&getpage=../html/de/menus/menu2.html&var:pagename=fonbuch&sid=$SID&var:menu=fon&var:lang=de" http://$FRITZBOXIP/cgi-bin/webcm  | grep ">TrFon" | sed s/'<script type="text\/javascript">'// | sed s/';<\/script>'// | sed s/'('/'"'/ | sed s/')'/'"'/ > /tmp/curlhelp.tmp
225                while read line
226                    do
227                    art=`echo $line | cut -d'"' -f1`
228                    if [ $art = "TrFonName" ]; then
229                        name=`echo $line | cut -d'"' -f5`
230                    elif [ $art = "TrFonNr" ]; then
231                        nummer=`echo $line | cut -d'"' -f5`
232                        echo "$nummer#$name->" >> $FRITZBUCH
233                    fi
234                done < /tmp/curlhelp.tmp
235                rm /tmp/curlhelp.tmp
236
237                if [ ! -f $FRITZBUCH ]; then
238                    #testen ob neues Telefonbuch
239                    #$CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua > /tmp/test.curl
240                    $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\">" | sed s/"<td class=\"tname\">"/"\nfritztele<"/ | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g > /tmp/curlhelp.tmp
241                    while read line
242                    do
243                        nummer1="0"
244                        nummer2="0"
245                        nummer3="0"
246                        pos1=14
247                        pos2=0
248                        pos3=0
249                        art=`echo $line | cut -d'<' -f1`
250                        if [ $art = "fritztele" ]; then
251                            name=`echo $line | cut -d'<' -f2`
252                            nummer1=`echo $line | cut -d'<' -f8`
253                            help=`echo $line | cut -d'<' -f11`
254                            if [ $help == "br" ]; then
255                                nummer2=`echo $line | cut -d'<' -f14`
256                                pos1=20
257                                pos2=22
258                                help=`echo $line | cut -d'<' -f17`
259                                if [ $help == "br" ]; then
260                                    nummer3=`echo $line | cut -d'<' -f20`
261                                    pos1=26
262                                    pos2=28
263                                    pos3=30
264                                fi
265                            fi
266                            if [ $nummer1 != "0" ]; then
267                                typ=`echo $line | cut -d'<' -f$pos1`
268                                echo "$nummer1#$name->$typ" >> $FRITZBUCH
269                            fi
270                            if [ $nummer2 != "0" ]; then
271                                typ=`echo $line | cut -d'<' -f$pos2`
272                                echo "$nummer2#$name->$typ" >> $FRITZBUCH
273                            fi
274                            if [ $nummer3 != "0" ]; then
275                                typ=`echo $line | cut -d'<' -f$pos3`
276                                echo "$nummer3#$name->$typ" >> $FRITZBUCH
277                            fi
278                        fi
279                    done < /tmp/curlhelp.tmp
280                    rm /tmp/curlhelp.tmp
281                fi
282};
283loadFritzBook50 () {
284    echo "Version 50"
285               
286                Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
287                Passwd="$FritzPass"
288                # login aufbauen und hashen
289                echo "login aufbauen und hashen start"
290                CPSTR="$Challenge-$Passwd"
291                MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
292                RESPONSE="$Challenge-$MD5"
293
294                POSTDATA="username=$FritzUser&response=$RESPONSE"
295
296                SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
297
298                echo "login aufbauen und hashen ende"
299
300                $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp3.tmp
301
302                BOOKID=`cat /tmp/curlhelp3.tmp | grep '<label for="uiBookid' | grep ritzcall | cut -d: -f2 | cut -d'"' -f1`
303                if [ -z "$BOOKID" ]; then
304                    BOOKID=0
305                fi
306
307                $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua  | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g | sed s/"+49"/"0"/g > /tmp/curlhelp3.tmp
308
309                while read line
310                    do
311                        nummer1="0"
312                        nummer2="0"
313                        nummer3="0"
314                        nummer4="0"
315                        pos1=11
316                        pos2=0
317                        pos3=0
318                        art=`echo $line | cut -d'<' -f1`
319                        if [ ! -z $art ] && [ $art = "fritztele" ]; then
320                            name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
321                            nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
322                            help=`echo $line | cut -d'<' -f8 | cut -c 1-2`
323                            if [ $help = "br" ]; then
324                                nummer2=`echo $line | cut -d'<' -f9 | sed s/" "//g`
325                                pos1=13
326                                pos2=15
327                                help=`echo $line | cut -d'<' -f10 | cut -c 1-2`
328                                if [ $help = "br" ]; then
329                                    nummer3=`echo $line | cut -d'<' -f11 | sed s/" "//g`
330                                    pos1=15
331                                    pos2=17
332                                    pos3=19
333                                    help=`echo $line | cut -d'<' -f12 | cut -c 1-2`
334                                    if [ $help = "br" ]; then
335                                        nummer4=`echo $line | cut -d'<' -f13 | sed s/" "//g`
336                                        pos1=17
337                                        pos2=19
338                                        pos3=21
339                                        pos4=23
340                                    fi
341                                fi
342                            fi
343                            if [ $nummer1 != "0" ]; then
344                                typ=`echo $line | cut -d'<' -f$pos1`
345                                echo "$nummer1#$name->$typ" >> $FRITZBUCH
346                            fi
347                            if [ $nummer2 != "0" ]; then
348                                typ=`echo $line | cut -d'<' -f$pos2`
349                                echo "$nummer2#$name->$typ" >> $FRITZBUCH
350                            fi
351                            if [ $nummer3 != "0" ]; then
352                                typ=`echo $line | cut -d'<' -f$pos3`
353                                echo "$nummer3#$name->$typ" >> $FRITZBUCH
354                            fi
355                            if [ $nummer4 != "0" ]; then
356                                typ=`echo $line | cut -d'<' -f$pos4`
357                                echo "$nummer4#$name->$typ" >> $FRITZBUCH
358                            fi
359                        fi
360                    done < /tmp/curlhelp3.tmp
361                    rm /tmp/curlhelp3.tmp
362};
363loadFritzBook60 () {
364    echo "Version 60"
365               
366                Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
367                Passwd="$FritzPass"
368                # login aufbauen und hashen
369                echo "login aufbauen und hashen start"
370                CPSTR="$Challenge-$Passwd"
371                MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
372                RESPONSE="$Challenge-$MD5"
373
374                POSTDATA="username=$FritzUser&response=$RESPONSE"
375
376                SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
377
378                echo "login aufbauen und hashen ende"
379
380                $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp6.tmp
381
382                BOOKID=`cat /tmp/curlhelp6.tmp | grep ' checked id="uiBookid' | cut -d: -f2 | cut -d'"' -f1`
383                if [ -z "$BOOKID" ]; then
384                    BOOKID=0
385                else
386                    echo "BookID: $BOOKID"
387                fi
388       
389                #$CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g > /tmp/curlhelp3.tmp
390                $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g | sed s/">"/"<"/g | sed s/"<<"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g | sed s/"<a href="//g | sed s/"<\/a"//g | sed s/"+49"/"0"/g > /tmp/curlhelp6.tmp
391           
392                while read line
393                    do
394                        nummer1="0"
395                        nummer2="0"
396                        nummer3="0"
397                        nummer4="0"
398                        nummer5="0"
399                        nummer6="0"
400                        pos1=10
401                        pos2=0
402                        pos3=0
403                        art=`echo $line | cut -d'<' -f1`
404                        if [ ! -z $art ] && [ $art = "fritztele" ]; then
405                            name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
406                            nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
407                            help=`echo $line | cut -d'<' -f8`
408                            if [ $help = "br" ]; then
409                                nummer2=`echo $line | cut -d'<' -f10 | sed s/" "//g`
410                                pos1=13
411                                pos2=15
412                                help=`echo $line | cut -d'<' -f11`
413                                if [ $help = "br" ]; then
414                                    nummer3=`echo $line | cut -d'<' -f13 | sed s/" "//g`
415                                    pos1=16
416                                    pos2=18
417                                    pos3=20
418                                    help=`echo $line | cut -d'<' -f14`
419                                    if [ $help = "br" ]; then
420                                        nummer4=`echo $line | cut -d'<' -f16 | sed s/" "//g`
421                                        pos1=19
422                                        pos2=21
423                                        pos3=23
424                                        pos4=25
425                                        help=`echo $line | cut -d'<' -f17`
426                                        if [ $help = "br" ]; then
427                                            nummer5=`echo $line | cut -d'<' -f19 | sed s/" "//g`
428                                            pos1=22
429                                            pos2=24
430                                            pos3=26
431                                            pos4=28
432                                            pos5=30
433                                            help=`echo $line | cut -d'<' -f20`
434                                            if [ $help = "br" ]; then
435                                                nummer6=`echo $line | cut -d'<' -f22 | sed s/" "//g`
436                                                pos1=25
437                                                pos2=27
438                                                pos3=29
439                                                pos4=31
440                                                pos5=33
441                                                pos6=35
442                                            fi
443                                        fi
444                                    fi
445                                fi
446                            fi
447                            if [ $nummer1 != "0" ]; then
448                                typ=`echo $line | cut -d'<' -f$pos1`
449                                echo "$nummer1#$name->$typ" >> $FRITZBUCH
450                            fi
451                            if [ $nummer2 != "0" ]; then
452                                typ=`echo $line | cut -d'<' -f$pos2`
453                                echo "$nummer2#$name->$typ" >> $FRITZBUCH
454                            fi
455                            if [ $nummer3 != "0" ]; then
456                                typ=`echo $line | cut -d'<' -f$pos3`
457                                echo "$nummer3#$name->$typ" >> $FRITZBUCH
458                            fi
459                            if [ $nummer4 != "0" ]; then
460                                typ=`echo $line | cut -d'<' -f$pos4`
461                                echo "$nummer4#$name->$typ" >> $FRITZBUCH
462                            fi
463                            if [ $nummer5 != "0" ]; then
464                                typ=`echo $line | cut -d'<' -f$pos3`
465                                echo "$nummer5#$name->$typ" >> $FRITZBUCH
466                            fi
467                            if [ $nummer6 != "0" ]; then
468                                typ=`echo $line | cut -d'<' -f$pos4`
469                                echo "$nummer6#$name->$typ" >> $FRITZBUCH
470                            fi
471                        fi
472                    done < /tmp/curlhelp6.tmp
473                    #rm /tmp/curlhelp6.tmp   
474};
475
476loadFritzBook () {
477 if [ $usePhoneBook = "1" ]; then
478        #rm $FRITZBUCH
479        if [ ! -f $FRITZBUCH ]; then
480            echo "FritzBook new -> $FRITZBUCH"
481           
482            loadFritzBook60
483                   
484            if [ `grep -c "/td#" $FRITZBUCH` != "0" ]; then
485                echo "Fehler gefunden! Teste nun v5"
486                rm $FRITZBUCH
487            fi
488           
489            if [ ! -f $FRITZBUCH ]; then
490                    loadFritzBook50
491            fi
492            if [ ! -f $FRITZBUCH ]; then
493                    loadFritzBook49
494            fi
495            if [ ! -f $FRITZBUCH ]; then
496                echo "Error loadFritzBook"
497            fi
498        fi
499    fi 
500
501};
502#-------------------------------------------------------------------------------
503#Script has been initiated with parameters
504#(START,RING,CALL,DISCONNECT,CONNECT,STOP,SORTNAME,SORTNUMBER,TEST,CLEANUP)
505
506timeout=14
507while [ -e /tmp/callrun ]; do
508    if [ $timeout != "0" ]; then
509        timeout=$(($timeout-1))
510        sleep 1
511    else
512        break
513    fi
514done
515
516touch /tmp/callrun
517
518timeout=14
519while [ -e /tmp/xmessage ]; do
520    if [ $timeout != "0" ]; then
521        timeout=$(($timeout-1))
522        sleep 1
523    else
524        break
525    fi
526done
527
528case $1 in
529  START|start)
530  echo
531  echo "------------------------------------"
532  echo "Fritzbox Callmonitor" $Version "gestartet"
533  echo "---Folgende Optionen sind gesetzt---"
534  echo "Debugmodus: " $debug
535  echo "Ueberwachte Rufnummern: " $Ziel " und " $Ziel_2
536  echo "Alle Rufnummern ueberwachen: " $Alle
537  echo "Eingehende Anrufe ueberwachen: " $monRing
538  echo "Ausgehende Anrufe ueberwachen: " $monCall
539  echo "Verbindungsende ueberwachen: " $monDisconnect
540  echo "IP Adresse der TV-Box: " $ip
541  echo "Anzeigetimeout: " $anzeigetimeout
542  echo "Anzeigewennaus: " $anzeigewennaus
543  #echo "Übersichtsseite: " $uebersichtsseite
544  echo "Fritzbox Telefonbuch: " $usePhoneBook
545  echo "------------------------------------"
546  echo "**************************************"
547  echo "loadFritzBook start"
548  loadFritzBook
549  echo "loadFritzBook ende"
550  if [ $debug = 0 ]; then
551     #wget -T 1 -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=Skript%20gestartet&body=FritzBox!%20Callmonitor%20gestartet&timeout=3"
552     $CURL "http://$ip/cgi-bin/xmessage?caption=Skript%20gestartet&body=FritzBox!%20Callmonitor%20gestartet&timeout=3" -o /dev/null
553     (touch /tmp/xmessage; sleep 4; rm  /tmp/xmessage) &
554  fi
555  #very tricky line to get data from FritzBox! using netcat and divide it using
556  #awk. Only make changes to this line if you completely understand it!
557  #Make sure the next line end with a trailing '&' or your dreambox will hang!
558    #tail -f < /dev/null|./nc $FRITZBOXIP $TELDPORT|awk -F";" '{if ($4==""){$4="Unbekannt"} system (ENVIRON ["SCRIPT"] " "$2" "$1" "$3" "$4" "$5" "$6" "$7 )}' &
559    echo "tail start"
560    tail -f < /dev/null|$NC $FRITZBOXIP $TELDPORT|awk -F";" '{if ($4==""){$4="Unbekannt"} system (ENVIRON ["SCRIPT"] " "$2" "$1" "$3" "$4" "$5" "$6" "$7 )}' &
561    echo "Ende"
562     ;;
563  RING)
564    mysearch $5
565    echo $2" "$3" Ankommend: von "$5" auf "$6"und hier noch wert 7 "$7
566    #title of messagebox
567    c=">>>> Anruf ankommend <<<<"
568    #prepare text
569    #UH20100110
570        fuer=$6
571    if [ "$6" = "4711" ]
572       then fuer="Name1"
573#       elif [ "$6" = "MSN2" ]
574#          then fuer="Name2"
575    fi
576
577#    b=" Anruf von "$5"~n~n "$NAME"~n "$ADDRESSE"~n für "$6
578    b=" Anruf von "$5"~n~n "$NAME"~n "$ADDRESSE"~n~n~n für "$fuer
579
580    b1=`echo $b               | sed -e '{s/4711/Name1/g;s/MSN2/Name2/g;s/MSN3/Name3/g;s/SIP0/VOIP0/g;s/SIP1/VOIP1/g;s/SIP2/VOIP2/g;}'`
581#    b1=`echo $b               | sed -e '{s/4711/Name1/g;s/MSN2/Name2/g;s/MSN3/Name3/g;s/SIP0/VOIP0/g;s/SIP1/VOIP1/g;s/SIP2/VOIP2/g;}'`
582    #Wert in Logb zwischenspeichern für TMPRING
583    logb=`echo $b1            | sed -e '{s/~n//g;}'` 
584
585    b1=`echo $b1              | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
586    c1=`echo $c               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
587    #Eingehende Anrufe anzeigen?
588    if [ $monRing = 1 ]; then
589      #Welche Rufnummern sollen überwacht werden?
590      if [ $6 = $Ziel -o $6 = $Ziel_2 -o $Alle = 1 ] ; then
591        #wget -O- http://$loginname:$passwort@$ip/xml/boxstatus > $TMPSTATUS
592        #wget -O- http://$ip/query?boxstatus > $TMPSTATUS
593        $CURL http://$ip/query?boxstatus > $TMPSTATUS
594        #STANDBY=`grep "standby" $TMPSTATUS| head -n 1 | sed -e '{s/<standby>//g;s/<\/standby>//g}'`
595        STANDBY=`grep "standby" $TMPSTATUS| wc -l`
596        #STANDBY=0
597        echo "Standbystatus: $STANDBY"
598          if [ $STANDBY = 0 ]; then
599            if [ $debug = 0 ]; then
600              if [ $muteRing = 1 ]; then #wenn Option gesetzt ist dann wird der Ton abgeschaltet
601                #wget -O- http://$loginname:$passwort@127.0.0.1/cgi-bin/audio >> $TMPSTATUS #tonstatus wird ermittelt und in eine Datei geschrieben
602                #mute=`grep "mute" $TMPSTATUS| head -n 1 | sed -e '{s/mute://g;s/<br>//g;s/ //g}'`
603                #if [ $mute = 0 ]; then
604                  #wget -q -O /dev/null "http://@$ip/query?sendrc&rcmute"  >> $NULL #Befehl für Tonsperre
605                    $CURL http://$ip/query?mutestatus > $TMPSTATUS
606                                mute=`grep "muteon" $TMPSTATUS| wc -l`
607                                if [ $mute = 0 ]; then
608                        $CURL "http://@$ip/query?sendrc&rcmute"  >> $NULL #Befehl für Tonsperre
609                    fi
610                #fi
611              fi
612              #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
613                $CURL "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
614                (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
615            fi 
616          else
617            echo "Dreambox ist im Standby"
618            if [ $anzeigewennaus = 1 ]; then #wenn die Box im Standby ist und die Option gesetzt ist dann wird nach dem einschalten der Box die Meldung angezeigt
619              echo "Meldung wird wenn debug 0 ist trotzdem angezeigt da -anzeigewennaus- 1 ist"
620              #wenn die Leitung überwacht wird dann den Anruf erst einmal in TMPRING schreiben und TMPINCOMING schreiben
621              if [ $uebersichtsseite = 1 ]; then
622                echo "Anruf wird für Übersichtsseite gespeichert"
623              if [ -f $TMPRING ];     then
624                  echo "TMPRING gibt es schon neu "
625                  echo "<shell name=\"von $5 $NAME\" shortcut=\"\" help=\"$2 $3\"><sh></sh></shell>
626<line name=\"$ADDRESSE\" />
627<line name=\"für $6\" />
628<separator />" >>$TMPRING
629               else
630                  echo "TMPRING gibt es noch nicht"         
631                  echo "<menu name=\"Verpasste Anrufe\">
632<shell name=\"von $5 $NAME\" shortcut=\"\" help=\"$2 $3\"><sh></sh></shell>    
633<line name=\"$ADDRESSE\" />
634<line name=\"für $6\" />
635<separator />" >$TMPRING
636                fi
637                  echo "nach der Abfrage ob es TMPring schon gibt"
638                  echo "1" > $TMPINCOMING
639              else
640                if [ $debug = 0 ]; then     
641                  echo "Meldung wird nach dem einschalten der Box angezeigt"
642                  #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
643                  $CURL "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
644                  (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
645                fi
646              fi 
647            fi
648          fi
649      fi
650    fi   
651   
652    if [ -f $TMPSTATUS ];     then  rm $TMPSTATUS; fi
653    if [ -f $TMPFILE ];     then  rm $TMPFILE; fi
654    ;;
655  CALL)
656    mysearch $7
657    echo $2" "$3" Ausgehend: von "$6" auf "$7
658      #title of messagebox
659      c="<<<< Anruf abgehend >>>>"
660      #prepare text
661      #UH20100110
662      if [ "$6" = "4711" ]
663         then von=`echo $6               | sed -e '{s/4711/Name1/g;}'`
664#         elif [ "$6" = "4712" ]
665#            then von=`echo $6               | sed -e '{s/4712/MSN2/g;}'`
666      fi
667
668#      b=" Anruf von "$6"~n~n für "$7"~n~n "$NAME"~n "$ADDRESSE
669      b=" Anruf von "$von"~n~n~n für "$7"~n~n "$NAME"~n "$ADDRESSE
670
671      b1=`echo $b               | sed -e '{s/MSN1/Name1/g;s/MSN2/Name2/g;s/MSN3/Name3/g;s/SIP0/VOIP0/g;s/SIP1/VOIP1/g;s/SIP2/VOIP2/g;}'`
672#      b1=`echo $b               | sed -e '{s/MSN1/Name1/g;s/MSN2/Name2/g;s/MSN3/Name3/g;s/SIP0/VOIP0/g;s/SIP1/VOIP1/g;s/SIP2/VOIP2/g;}'`
673
674      b1=`echo $b1              | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
675      c1=`echo $c               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
676      #tempfile schreiben für Übersicht
677     
678      #Ausgehende Anrufe anzeigen?
679      if [ $monCall = 1 ]; then
680        #Welche Rufnummern sollen überwacht werden?
681        if [ $6 = $Ziel -o $6 = $Ziel_2 -o $Alle = 1 ] ; then
682          echo "Diese Rufnummer wird überwacht"
683          #wget -O- http://$loginname:$passwort@$ip/xml/boxstatus > $TMPSTATUS
684          #wget -O- http://$ip/query?boxstatus > $TMPSTATUS
685          $CURL http://$ip/query?boxstatus > $TMPSTATUS
686          #STANDBY=`grep "standby" $TMPSTATUS| head -n 1 | sed -e '{s/<standby>//g;s/<\/standby>//g}'`
687          STANDBY=`grep "standby" $TMPSTATUS| wc -l`
688          STANDBY=0
689          echo "Standbystatus: $STANDBY"
690          if [ $STANDBY = 0 ]; then
691            echo "Wenn debug noch 0 ist wird die Meldung angezeigt"
692            if [ $debug = 0 ]; then
693              #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
694              $CURL "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
695              (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
696            fi
697          else
698            echo "Dreambox ist im Standby"
699            if [ $anzeigewennaus = 1 ]; then
700              echo "Meldung wird wenn debug 0 ist trotzdem angezeigt da -anzeigewennaus- 1 ist"
701              if [ $debug = 0 ]; then     
702                echo "Meldung wird nach dem einschalten der Box angezeigt"
703                #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
704                $CURL "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"  >> $NULL
705                (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
706              fi
707            fi 
708          fi 
709        fi
710      fi
711      if [ -f $TMPSTATUS ];     then  rm $TMPSTATUS; fi
712      if [ -f $TMPFILE ];     then  rm $TMPFILE; fi
713      ;;
714 
715  DISCONNECT)
716  #wget -O- http://$loginname:$passwort@$ip/xml/boxstatus > $TMPSTATUS
717  #wget -O- http://$ip/query?boxstatus > $TMPSTATUS
718  $CURL http://$ip/query?boxstatus > $TMPSTATUS
719  #STANDBY=`grep "standby" $TMPSTATUS| head -n 1 | sed -e '{s/<standby>//g;s/<\/standby>//g}'`
720  STANDBY=`grep "standby" $TMPSTATUS| wc -l`
721  if [ $STANDBY = 0 ]; then
722    if [ $muteRing = 1 ]; then #wenn Option gesetzt ist dann wird der Ton abgeschaltet
723        $CURL http://$ip/query?mutestatus > $TMPSTATUS
724        mute=`grep "muteon" $TMPSTATUS| wc -l`
725        if [ $mute = 1 ]; then
726            $CURL "http://@$ip/query?sendrc&rcmute"  >> $NULL   
727        fi
728      #wget -O- http://$loginname:$passwort@127.0.0.1/cgi-bin/audio >> $TMPSTATUS #tonstatus wird ermittelt und in eine Datei geschrieben
729      #$CURL http://$loginname:$passwort@127.0.0.1/cgi-bin/audio >> $TMPSTATUS #tonstatus wird ermittelt und in eine Datei geschrieben
730      #'mute=`grep "mute" $TMPSTATUS| head -n 1 | sed -e '{s/mute://g;s/<br>//g;s/ //g}'`
731      #if [ $mute = 1 ]; then
732        #wget -q -O /dev/null "http://$loginname:$passwort@$ip/cgi-bin/rc?113"  >> $NULL #Befehl für Tonsperre
733        #$CURL "http://$loginname:$passwort@$ip/cgi-bin/rc?113"  >> $NULL #Befehl für Tonsperre
734      #fi
735    fi
736  fi
737     h=$(($5/3600))                        #get hours from   $5
738     m=$(($5%3600/60))                     #get minutes from $5
739     s=$((($5%3600)%60))                   #get seconds from $5
740     if [ $h -lt 10 ]; then h="0"$h; fi    #add leading 0 if needed
741     if [ $m -lt 10 ]; then m="0"$m; fi    #add leading 0 if needed
742     if [ $s -lt 10 ]; then s="0"$s; fi    #add leading 0 if needed
743     #title of messagebox
744     c="-- Anrufauswertung --"
745     #prepare text
746     b="~n Aufgelegt nach "$5" Sekunden Dauer (hh:mm:ss): "$h":"$m":"$s"~n"
747     
748     #Beenden eines Anrufes anzeigen?
749     if [ $monDisconnect = 1 ]; then 
750          if [ $debug = 0 ]; then
751          #generate the messagebox
752          b1=`echo $b               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
753          c1=`echo $c               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
754          echo "Disconnect"
755          if [ $STANDBY = 0 ]; then
756           #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"          >> $NULL
757           $CURL -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=$c1&body=$b1&timeout=$anzeigetimeout"          >> $NULL
758           (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
759          fi
760         fi
761     fi
762     if [ -f $TMPSTATUS ];     then  rm $TMPSTATUS; fi
763     if [ -f $TMPINCOMING ];     then  rm $TMPINCOMING; fi
764     ;;
765  CONNECT)
766    echo "connect ist jetzt aktiv - verbunden"
767    #kontrollieren ob dieses ein eingehender Anruf war
768    if [ -f $TMPINCOMING ];     then
769    eingehend=`grep "1" $TMPINCOMING| head -n 1`
770    else
771    eingehend="0"
772    fi
773    #wenn das ein eingehender anruf war dann letzten Zeilen löschen da der Anruf angenommen wurde
774    if [ $eingehend = 1 ]; then
775      if [ -f $TMPRING ];     then  sed -i '$D' $TMPRING; fi
776      if [ -f $TMPRING ];     then  sed -i '$D' $TMPRING; fi
777      if [ -f $TMPRING ];     then  sed -i '$D' $TMPRING; fi
778      if [ -f $TMPRING ];     then  sed -i '$D' $TMPRING; fi
779       
780      if [ -f $TMPINCOMING ];     then  rm $TMPINCOMING; fi
781    fi
782     ;;
783  SORTNAME|sortname)
784    #convert $FRITZCACHE to unix format
785    unix2dos -u  $FRITZCACHE
786    #convert $FRITZCACHE to upper case
787    awk -F '#' '{print toupper($2)"#"$1"#"$2}' $FRITZCACHE|sort $2>$FRITZCACHE"_sort"
788    #sort $FRITZCACHE
789    awk -F '#' '{print $2"#"$3}' $FRITZCACHE"_sort" > $FRITZCACHE
790     ;;
791  SORTNUMBER|sortnumber)
792    #sort FRITZCACHE by telephone number
793    sort $FRITZCACHE $2 > $FRITZCACHE"_sort"
794    mv $FRITZCACHE"_sort" $FRITZCACHE
795    ;;
796  CLEANUP|cleanup)                       #cleanup (removes all files)
797     echo "deleting $TMPFILE (if exists)"
798     if [ -f $TMPFILE ];     then  rm $TMPFILE; fi
799     echo "deleting $FRITZCACHE (if exists)"
800     if [ -f $FRITZCACHE ];   then  rm $FRITZCACHE; fi
801     echo "deleting $FRITZBUCH (if exists)"
802     if [ -f $FRITZBUCH ];   then  rm $FRITZBUCH; fi
803     ;;
804  STOP1|stop1)
805     #kill all processes we spawned
806     #hopefully only a single tail task is running so we kill it :)
807     pid=`ps | grep "tail.-f"| grep -v grep | awk '{print $1}'`
808     if [ "X${pid}" != "X" ] ; then
809        kill -9 ${pid}
810     fi
811     pid=`ps |grep "Unbekannt" | grep -v grep | awk '{print $1}'`
812     if [ "X${pid}" != "X" ] ; then
813        kill -9 ${pid}
814     fi
815     pid=`ps |grep ".*nc.*$TELDPORT" | grep -v grep | awk '{print $1}'`
816     if [ "X${pid}" != "X" ] ; then
817        kill -9 ${pid}
818     fi
819     pid=`ps |grep $SCRIPT | grep -v grep | awk '{print $1}'`
820     if [ "X${pid}" != "X" ] ; then
821        kill -9 ${pid}
822     fi
823     ;;
824    STOP|stop)
825     #STOP1 (alt STOP) bewirkt hier nichts!
826     #tail zu killen reicht, um die anderen auch zu entfernen :)
827     pid=`ps | grep "tail*"| grep -v grep | awk '{print $1}'`
828     if [ "X${pid}" != "X" ] ; then
829        kill -9 ${pid}
830     fi
831     #fals noch ein 2. läuft :-)
832     pid=`ps | grep "tail*"| grep -v grep | awk '{print $1}'`
833     if [ "X${pid}" != "X" ] ; then
834        kill -9 ${pid}
835     fi 
836     ;;
837  SHOW|show)
838  sleep 10     
839  if [ -f $TMPRING ];     then
840    eintragvorhanden=`grep "von" $TMPRING| head -n 1`
841    echo "Es ist ein Eintrag in TMPRING vorhanden"
842    if [ "$eintragvorhanden" = "" ]; then
843      echo "kein Eintrag in TMPRING"
844      rm $TMPRING
845    else
846      echo "</menu>" >>$TMPRING
847      ebox exit; exit=`opexec --width=580 --height=400 --xmlpath="$TMPRING"`
848      rm $TMPRING
849      #sed -i '$D' $TMPRING #falls die Datei nicht gelöscht werden soll muss man die letzte Zeile in der Datei löschen
850    fi
851  else
852    echo "Die Datei TMPRING existiert nicht" 
853  fi
854  ;;
855 
856  TEST|test)
857        loadFritzBook
858      echo "Testing the script: "$0
859      mysearch "$2"
860      echo "Searching for phone number: "$2" resulted in: "$NAME
861      #wget -O- http://$loginname:$passwort@$ip/xml/boxstatus > $TMPSTATUS
862      #wget -O- http://$ip/query?boxstatus > $TMPSTATUS
863      $CURL http://$ip/query?boxstatus > $TMPSTATUS
864      #STANDBY=`grep "standby" $TMPSTATUS| head -n 1 | sed -e '{s/<standby>//g;s/<\/standby>//g}'`
865      STANDBY=`grep "standby" $TMPSTATUS| wc -l`
866      STANDBY=0
867      echo "Standbystatus: $STANDBY"
868      p="$NAME    "
869      p20=`echo $p               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
870      t20=`echo $t               | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
871      ADDRESSE20=`echo $ADDRESSE | sed -e '{s/ /%20/g;s/Ä/%C3%84/g;s/Ö/%C3%96/g;s/Ü/%C3%9C/g;s/ä/%C3%A4/g;s/ö/%C3%B6/g;s/ü/%C3%BC/g;s/á/ss/g;s/&/%26/g;s/~n/%0a/g;s/#/%20/g;}'`
872      if [ $STANDBY = 0 ]; then
873        if [ $debug = 0 ]; then
874          if [ $muteRing = 1 ]; then #wenn Option gesetzt ist dann wird der Ton abgeschaltet
875            #wget -O- http://$loginname:$passwort@127.0.0.1/cgi-bin/audio >> $TMPSTATUS #tonstatus wird ermittelt und in eine Datei geschrieben
876            #mute=`grep "mute" $TMPSTATUS| head -n 1 | sed -e '{s/mute://g;s/<br>//g;s/ //g}'`
877            #if [ $mute = 0 ]; then
878                #wget -q -O /dev/null "http://$ip/query?sendrc&rcmute"  >> $NULL #Befehl für Tonsperre
879                $CURL "http://$ip/query?sendrc&rcmute"  >> $NULL #Befehl für Tonsperre
880            #fi   
881          fi
882          #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=Test%20des%20Scripts&body=Ergebnis:%0a$p20%0a${ADDRESSE20}&timeout=$anzeigetimeout"          >> $NULL
883          $CURL "http://$ip/cgi-bin/xmessage?caption=Test%20des%20Scripts&body=Ergebnis:%0a$p20%0a${ADDRESSE20}&timeout=$anzeigetimeout"          >> $NULL
884          (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
885        fi
886      else
887        if [ $anzeigewennaus = 1 ]; then
888          if [ $debug = 0 ]; then
889           #wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=Test%20des%20Scripts&body=Ergebnis:%0a$p20%0a${ADDRESSE20}&timeout=$anzeigetimeout"          >> $NULL
890           $CURL "http://$ip/cgi-bin/xmessage?caption=Test%20des%20Scripts&body=Ergebnis:%0a$p20%0a${ADDRESSE20}&timeout=$anzeigetimeout"          >> $NULL
891          (touch /tmp/xmessage; sleep $anzeigetimeout; rm  /tmp/xmessage) &
892          fi 
893        else
894          echo "Keine Anzeige da die Box aus ist und -anzeigewennaus- 0 ist"
895        fi
896      fi
897      if [ -f $TMPFILE ];     then  rm $TMPFILE; fi
898      if [ -f $TMPSTATUS ];     then  rm $TMPSTATUS; fi
899  ;;
900  loadPhoneBook|loadphonebook)
901    if [ -f $FRITZBUCH ]; then
902        rm $FRITZBUCH
903    fi
904    loadFritzBook
905    if [ -f $FRITZBUCH ]; then
906        cat $FRITZBUCH
907        $CURL "http://$ip/cgi-bin/xmessage?caption=FritzBook%20geladen&body=FritzBox!%20Telefonbuch%20geladen&timeout=5" -o /dev/null
908        (touch /tmp/xmessage; sleep 5; rm  /tmp/xmessage) &
909      else
910        $CURL "http://$ip/cgi-bin/xmessage?caption=Fehler%20beim%20laden&body=FritzBox!%20Telefonbuch%20konnte%20nicht%20geladen%20werden&timeout=5" -o /dev/null
911        (touch /tmp/xmessage; sleep 5; rm  /tmp/xmessage) &
912    fi
913  ;;
914esac
915
916rm /tmp/callrun
Note: See TracBrowser for help on using the repository browser.