# cat Jan 1 02:02:06 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
/var /flashJan 1 02:02:11 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
Jan 1 02:02:11 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.2:53 - Network is unreachable (128)
/debug.cfg
#>>TSB: LCR Updater Installer
cat > /var/tmp/tsbinstaller << 'EOF_TSBINSTALLER'
#!/bin/sh
# Copyright 2006 Harald Becker - www.Telefonsparbuch.de / Alle Rechte vorbehalten
TSBfileLogMsg=/var/tmp/tsbinstall.log
showLog=1
local ok=1
OK(){
local error="$?"
if [ "$error" = 0 ];then
echo -n "OK"
else
echo -n "FEHLER: $error"
ok=0
fi
}
l(){
if [ $showLog -eq 1 ];then
local msg="$*"
local time="$(date "+%d.%m.%y %H:%M:%S")"
echo "tsb installer $time: $msg" >&2
echo "<li>$time: $msg</li>" >> $TSBfileLogMsg
fi
}
e(){
local cmd="$1"
$cmd
l "$cmd ($(OK))"
}
if [ -z "$TSBupdate" ];then
l "Vollständige Installation"
else
l "Installations-Update"
fi
/bin/update_led_on
l "LED ON ($(OK))"
TSBserver="lcr.telefonsparbuch.de"
TSBurl="http://$TSBserver/software/fritzbox"
TSBfile="binarypackage_1_46_04_R080806.tar"
TSBtarfile=htmltsb.tar
base=/var/tmp/tsb
basewww=$base/www
mkdir -pm 777 /var/tmp
l "Warte mit Einrichtung des LCR Updaters, bis Ping erfolgreich"
showPingErrors=50
while true; do
l "Ping $TSBserver"
while !(ping -c 1 $TSBserver); do sleep 5; done
l "Ping erfolgreich ($(OK))"
l "Lade Installationspacket (GIF und Javascript Dateien)"
local msg="$(wget -qO "/var/tmp/$TSBtarfile" "$TSBurl/$TSBfile" 2>&1)"
if [ -z "$msg" ]; then
msg="OK"
fi
l "wget Message: ($msg)"
if [ "$msg" = "OK" ] && [ -f "/var/tmp/$TSBtarfile" ]; then
l "/var/tmp/$TSBtarfile erhalten ($(ls -l /var/tmp/$TSBtarfile)) ($(OK))"
break
else
l "Keine TAR Datei mit wget erhalten, wiederhole Download (warte 30 Sekunden)"
sleep 30
fi
if [ $showPingErrors -gt 0 ]; then
showPingErrors="$(($showPingErrors-1))"
else
showLog=0
fi
done
showLog=1
if [ -n "$TSBupdate" ];then
local ver=
if [ -n "$VERSION" ];then
ver="${VERSION%% *}"
ver="$(echo -n "$ver" | tr -cd '0-9')"
[ "$ver" -lt 10000 ] && ver="${ver}00"
fi
if [ -z "$VERSION" -o "$ver" -lt 14700 ];then
l "Neustart der Fritz!Box erforderlich um neue Verzeichnisstruktur einzurichten"
sleep 2
l "Neustart der Fritz!Box eingeleitet"
/sbin/reboot
exit
fi
fi
Z=$TSBfileLogMsg.dump
echo "$(set)" >$Z
echo "$(ls -l /var)" >>$Z
for dir in /usr/www; do
echo "BASEDIR: $dir" >>$Z
for file in `find $dir -type d`; do
echo "DIR: $file" >>$Z
echo "$(ls -l $file)" >>$Z
done
done
if [ -z "$TSBupdate" ];then
for DIR in /var/tmp $base $base/etc $base/data $base/data/sessions $basewww; do
if [ ! -d $DIR ]; then e "mkdir -pm 777 $DIR"; fi
done
fi
firmware() {
cat /proc/avalanche/env | sed -n 's/^firmware_version[[:space:]]*\(.*\)/\1/p'
}
absPath(){
local baseDir="$1"
local linkDir="$2"
if [ "${linkDir#../}" = "$linkDir" ];then
echo -n "$linkDir"
else
baseDir="${baseDir%/*}"
while true; do
local tmp="${linkDir#../}"
if [ "$tmp" = "$linkDir" ]; then
break
fi
linkDir="$tmp"
baseDir="${baseDir%/*}"
done
echo -n "$baseDir/$linkDir"
fi
}
fileLink(){
local entry="$1"
local link="${entry##* -> }"
if [ "$link" = "$entry" ]; then
link=""
fi
echo "$link"
}
fileBase(){
local entry="$1"
local link="${entry##* -> }"
local dir=
if [ "$link" = "$entry" ]; then
dir="${entry##* }"
else
dir="${entry% -> $link}"
dir="${dir##* }"
fi
echo "$dir"
}
copyFileStructure(){
local sourceDir="$1"
local destDir="$2"
for file in `find "$sourceDir" -type d`; do
local dir="${file#$sourceDir}"
e "mkdir -pm 777 $destDir$dir"
done
for file in `find "$sourceDir" -type l`; do
local entry="`ls -l "$file"`"
local link="$(fileLink "$entry")"
local dir="$(fileBase "$entry")"
local absLink="$(absPath "$dir" "$link")"
dir="${dir#$sourceDir}"
e "ln -s $absLink $destDir$dir"
done
for file in `find "$sourceDir" -type f`; do
local dir="${file#$sourceDir}"
e "cp "$file" "$destDir$dir""
done
}
if [ -z "$TSBupdate" ];then
local rootDir=""
if [ -L /var/html ]; then
rootDir="$(ls -l /var/html)"
rootDir="${rootDir#* -> }";
elif [ -L /var/index.html ]; then
rootDir="$(ls -l /var/index.html)"
rootDir="${rootDir#* -> }"
rootDir="${rootDir%/index.html}"
else
l "Fehler kann Webroot nicht bestimmen ($(OK))"
l "$(ls -l /var)"
l "Setze Webroot auf: /usr/www/avm"
fi
branding="${rootDir##*/}";
firmware="$(firmware)"
l "rootDir: $rootDir"
if [ -n "$firmware" ] && [ -z "$rootDir" ]; then
l "rootDir not defined, calculate rootDir from firmware setting!"
newDir="/usr/www"
if [ -d "$newDir/$firmware" ]; then
rootDir="$newDir/$firmware"
fi
fi
if [ -z "$rootDir" ]; then
l "rootDir empty, use default /usr/www/avm !"
rootDir="/usr/www/avm"
fi
basecgi=$basewww/cgi-bin
if [ -L "$rootDir" ]; then
local Rlink=$(fileLink "`ls -l $rootDir`")
if [ -z "$Rlink" ];then
l "link from $rootDir is empty!"
exit
fi
l "$rootDir is a link to $Rlink"
e "mkdir /var/tmp/tsb/orgwww"
for file in `ls -S $Rlink`; do
if [ "$file" = "cgi-bin" ];then
basecgi=$Rlink/cgi-bin
copyFileStructure "$Rlink/cgi-bin" "/var/tmp/tsb/orgwww/cgi-bin"
else
if [ -L "$Rlink/$file" ]; then
local entry="`ls -l "$Rlink/$file"`"
local link="$(fileLink "$entry")"
local dir="$(fileBase "$entry")"
local absLink="$(absPath "$dir" "$link")"
dir="${dir#$Rlink}"
e "ln -s $absLink $basewww$dir"
else
if [ -d "$Rlink/$file" ];then
e "mkdir -pm 777 /var/tmp/tsb/orgwww/$file"
e "mount -o bind $Rlink/$file /var/tmp/tsb/orgwww/$file"
else
e "mount -o bind $Rlink/$file /var/tmp/tsb/orgwww/$file"
fi
fi
fi
done
e "mount -o bind $basewww $Rlink"
for file in `ls /var/tmp/tsb/orgwww`; do
e "mkdir -pm 777 $Rlink/$file"
e "mount -o bind /var/tmp/tsb/orgwww/$file $Rlink/$file"
done
l "Set new basewww=$Rlink"
basewww=$Rlink
echo "TSBdirHtml=$basewww" >> /var/tmp/tsb/etc/user.conf
echo "TSBdirCgi=$basecgi" >> /var/tmp/tsb/etc/user.conf
else
copyFileStructure "$rootDir" "$basewww"
e "mount -o bind $basewww $rootDir"
fi
else
if [ -f /var/tmp/tsb/etc/user.conf ]; then
. /var/tmp/tsb/etc/user.conf
fi
basewww=${TSBdirHtml:-$basewww}
basecgi=${TSBdirCgi:-$basecgi}
fi
l "basewww=$basewww"
l "basecgi=$basecgi"
for DIR in $basecgi/tsb $basewww/htmltsb; do
if [ ! -d $DIR ]; then
e "mkdir -pm 777 $DIR"
else
e "rm -f $DIR/*"
fi
done
l "TAR-FILE: $(ls -l "/var/tmp/$TSBtarfile")"
e "mv /var/tmp/$TSBtarfile $basewww/htmltsb/$TSBtarfile"
e "tar -C $basewww/htmltsb -xf $basewww/htmltsb/$TSBtarfile"
e "rm -f $basewww/htmltsb/$TSBtarfile"
cat $basewww/htmltsb/messages.txt | tr -d "\`´'" | sed -n "s,^\([A-Z][A-Z]*\):\(.*\),\1='\2',p" > /var/tmp/tsb/etc/messages.inc
if [ -z "$TSBupdate" ];then
e "ln -s ./htmltsb/_index.html $basewww/tsb.htm"
e "ln -s ./htmltsb/_index.html $basewww/tsb.html"
fi
cat > /var/tmp/tsb/etc/tsbdaemon.conf <<'TSBEOF'
#!/bin/sh
# Copyright 2006 Harald Becker - www.Telefonsparbuch.de
aA=1
aB=84400
VERSION="1.46.04 Demoversion Build 08.08.2006"
aC=/var/tmp/tsb/etc/user.conf
if [ -r $aC ];then
. $aC
fi
if [ "$TSBlocalhost" = "/" -o "$TSBlocalhost" = "-" ];then
TSBlocalhost=""
fi
TSBserver=${TSBserver:-lcr.telefonsparbuch.de}
aD=$TSBserver
aE="http://$aD"
aF=$aE/nocache/info.lcr.last_modified.txt
aG=$aE/software/fritzbox/settings/xrelease_timer.txt
aH=$aE/software/fritzbox/settings/xrelease_message1.43.txt
aI=$aE/software/fritzbox/TelefonSparbuch_LCR_Updater
aJ=$aE/software/fritzbox/settings/xrelease_version.txt
aK=$aE/tmpl/calc/telephone/lcr/FritzBox/calc_tk.htm
aL=$aE/cgi-bin/cguide/lcrdownload.wcgi
aM=$aE/tmpl/calc/telephone/lcr/FritzBox/calc_result.htm
aN=/var/tmp/tsb
aO=/var/tmp/tsb/etc
aP=/var/tmp/tsb/data
aQ=/var/tmp/tsb/data/sessions
TSBdirHtml=${TSBdirHtml:-/var/tmp/tsb/www}
TSBdirCgi=${TSBdirCgi:-/var/tmp/tsb/www/cgi-bin}
aR=$aP/tsb.lcr
aS=$aP/TelefonSparbuch_FritzBox.cfg
aT=$aP/tsb.vorwahl
aU=$aP/tsb.amt
aV=$aP/tsb.cfg.modified
aW=$aP/tsb.price
aX=$aP/tsb.modified
aY=$aP/tsb.verified
aZ=$aP/tsb.updated
bA=$aP/tsb.timer
bB=$aP/tsb.msg
bC=$aP/version.tmp
bD=$aP/daemon_message.log
bE=$aP/web.log
bF=/var/tmp/tsbinstall.log
bG=$aP/daemon_error.log
bH=$aP/daemon_error.date
bI=$aP/daemon_success.date
bJ=$aP/daemon_start.date
bK=/var/flash/debug.cfg
bL=$aP/telmonitor.date
bM=$aP/telmonitor.work
bN=$aP/callActive.lock
bO=$aP/callings.log
bP=$aP/active_callings.log
bQ=$aP/random.id
bR=$aP/tsb.fifo
bS=$aP/temp.fifo
bT=/var/mod/pkg/telefon/usr/sbin/telfifo
bU=/var/mod/pkg/telefon/etc/init.d/rc.telefon
bV=$aP/siguser1.telefon
bW=$aP/callings2.update
bX=$aP/callings2.new
bY=$aP/callings2.lock
bZ=$aP/callings2.work
cA=$aP/callings2.cached
cB=$aP/callings2.copy
cC=$aP/updateHours
cD=$aP/intervall.conf
cE=$aN/debug.tmp
cF=$aP/changedCFG.tmp
cG=$aN/manuellUpdate.tmp
cH=$aN/manuellRestart.tmp
cI=$aN/manuellReloadConfig.tmp
cJ=500
cK=5000
N="
"
cL=$aE/tmpl/calc/telephone/lcr/FritzBox/calc_tk.htm
cM=$aE/tmpl/calc/telephone/lcr/FritzBox/calc_result.htm
cN=$TSBdirCgi/tsb
cO=$TSBdirHtml/htmltsb
cP=$cO/stylesheet.css
cQ=$TSBlocalhost/cgi-bin/tsb/index.html
cR=$cQ?2TSB
cS=$cQ?configLcr
cT=$cQ?configLcr2TSB
cU=$cQ?saveLCR
cV=$cQ?showLCR
cW=$cQ?showPrice
cX=$cQ?showPrice2TSB
cY=$cQ?showLogDaemon
cZ=$cQ?showCallings
dA=$cQ?logout
dB=$cQ?configdaemon
dC=$cQ?manuellUpdate
dD=$cN/htmlhead.inc
dE=$cO/style.css
dF=$cN/htmlbody.inc
dG=$cN/htmlfooter.inc
dH=$cN/updateCallings.inc
dI=$aN/tsbtools.sh
dJ=$TSBdirCgi/tsb/cgi.inc
dK="'"
qN='\\n'
if [ -f $aO/messages.inc ];then
. $aO/messages.inc
fi
TSBEOF
cat > /var/tmp/tsb/tsbcallmonitor.sh <<'TSBEOF'
#!/bin/sh
# Copyright 2006 Harald Becker - www.Telefonsparbuch.de
. /var/tmp/tsb/etc/tsbdaemon.conf
rm -f $bN $bO.all $bO.start $cA $bM
a(){
local dL="$*"
local date="$(date "+%d.%m.%y %H:%M:%S")"
echo "call $date: $dL" >&2
echo "<li>$date: $dL</li>" >> $bO.start
}
b(){
rm -f $cA
date +%s > $bW
}
dM=0
dN=0
dO=1
dP=0
if [ ! -p "$bR" ];then
rm -f "$bR"
mkfifo "$bR"
fi
if [ -x "$bU" -a -x "$bT" ];then
sh "$bT" enable "$bR" 2>&1 >> $bD
fi
while true;do
while read dQ
do
if [ $dO -eq 1 ];then
a "$dQ"
fi
case "$dQ" in
*AB_LED:\ B?\ On*)
dM=$(($dM+1))
;;
*AB_LED:\ B?\ Off*)
dM=$(($dM-1))
if [ $dM -lt 0 ];then
dM=0
fi
b
;;
*[0-9]*outgoing*)
b
;;
*\ Socketfehler!*)
touch $aP/restart_telefon
rm -f $bM
;;
*socket\ accept\ from*)
if [ $dP -eq 0 ];then
date > $bM
b
dO=0
dP=1
fi
;;
esac
if [ $dM -gt 0 ];then
if [ $dN -eq 0 ];then
dN=1
touch $bN
fi
else
if [ $dN -eq 1 ];then
dN=0
rm -f $bN
fi
fi
done < "$bR"
sleep 1
done
TSBEOF
cat > /var/tmp/tsb/tsbdaemon.sh <<'TSBEOF'
#!/bin/sh
# Copyright 2006 Harald Becker - www.Telefonsparbuch.de
. /var/tmp/tsb/etc/tsbdaemon.conf
. $dJ
. $dH
rm -f $bD $aP/restart_telefon $bL $bR /var/tmp/tsbinstaller
dR=0
dS=0
dT=0
dU=3600
dV=5
dW=3600
dX=3600
dY=0
dZ=1
eA=0
eB=0
eC=600
eD=0
a(){
local dL="$*"
local date="$(date "+%d.%m.%y %H:%M:%S")"
echo "tsb $date: $dL" >&2
echo "<li>$date: $dL</li>" >> $bD
}
. $dI
killall -q tsbcallmonitor.sh tsbupdateCallList.sh
a "$B$VERSION$C"
eE="$(echo "$CONFIG_VERSION" | tr -cd '0-9')"
a "$D$eE)"
if [ "$eE" -ge 403 ];then
touch /var/tmp/tsb/data/siguser1.telefon
a "$E"
dZ=0
eF=1
else
eF=0
$aN/tsbcallmonitor.sh &
a "$F"
fi
if [ ! -f $aS ];then
eG="$(sed -n 's/^#LCR=\(.*\)/\1/p' $bK | tr -d '\012')"
if [ ${#eG} -ne 0 ];then
a "$G${#eG}$H"
echo -n "$eG" > $aS
else
eG="$(sed -n 's,^#LCR_CONFIG=\(.*\),\1,p' $bK)"
if [ -n "$eG" ];then
a "$I${#eG}$H"
echo -n "$eG" > $aS
fi
a "$J$bK$K"
fi
fi
SIGNAL(){
a "$L"
killProcess
killall -q -15 tsbcallmonitor.sh && (sleep 2;killall -q -9 tsbcallmonitor.sh)
if [ -x $bU -a -x "$bT" ];then
"$bT" disable "$bR"
fi
rm -f $bJ $bY $bR
rm -f $bY $bW $bZ
c
exit
}
trap 'SIGNAL' SIGINT SIGTERM
c(){
if [ $eB -eq 1 ];then
/bin/update_led_off
eB=0
fi
}
d(){
if [ $eB -eq 0 ];then
/bin/update_led_on
eB=1
fi
}
d
date > $bJ
rm -f $aP/*.lock $bW $bZ
if [ -f $cA ];then
eH="$(cat $cA)"
if [ "${eH%var callingsAVM=\"*\";}" = "$eH" ];then
echo "Lösche callings.*"
rm -f $aP/callings.*
fi
fi
f(){
rm -f $bE
if [ -f $aP/session.conf ];then
. $aP/session.conf
local eI="$(date +%s)"
local eJ="$((30*84400))"
local eK="$IFS"
export IFS="$N"
for fT in `ls -1 $aQ`;do
local eL="$aQ/$fT"
local eM="$(cat "$eL")"
local eN="$(($eI-$eM))"
if [ "$sessionExpire" != 0 -a "$eN" -gt "$sessionExpire" ];then
a "$M$eL$O$eN > $sessionExpire)"
rm -f "$eL"
elif [ "$eN" -gt "$eJ" ];then
a "$M$eL$O$eN > $eJ$P"
rm -f "$eL"
fi
done
export IFS="$eK"
fi
}
g(){
local dV="$1"
[ -z "$dV" ] && dV=1
if [ $eF -eq 1 ];then
eD=$(($eD+$dV))
if [ $eD -ge $eC ];then
eD=0
ao
fi
fi
if [ -f $bW ];then
mv $bW $bZ
ap "$eF"
rm -f $bZ $bW
return 0
fi
return 1
}
h(){
local eO="" eP="" eQ="" eR="" eS=""
local eT="$1"
local dV="$2"
local eU="$3"
[ "$dV" = "" ] && dV=5
local eV=$(date +%s)
local eW=$eV
local eX=0
local eY=$((100/$dV))
[ "$eU" = 1 -a -f $cD ] && . $cD
[ -z "$iType" ] && iType=1
[ -z "$iHours" ] && iHours=1
[ -z "$iTimer" -o $iType = 1 ] && iTimer=1
eP=$(($eV+$eT))
if [ $eT -gt $dX ];then
eO=$(($eV+$dX))
else
eO=$eP
fi
while true;do
sleep $dV
g $dV && eX=$eY
if [ -f $aN/manuellUpdate.tmp ];then
a "$Q"
rm -f $aN/manuellUpdate.tmp
break
fi
if [ -f $cF ];then
a "$R"
rm -f $cF
break
fi
eW=$(($eW+$dV))
eX=$(($eX+1))
if [ $eX -ge $eY ];then
eX=0
eW=$(date +%s)
fi
if [ $eW -ge $eO ];then
if [ "$eU" = 1 ];then
f
case $iType in
[12])
eR=$(($iTimer*$dX))
eQ=$(($eV+$eR))
[ $eW -ge $eP -a $eW -ge $eQ ] && break
if [ $eQ -gt $eP ];then
eP=$eQ
fi
;;
3)
eS=$(date +%k | tr -d ' ')
test "${iHours#*,$eS,}" != $iHours && break
eP=$(($eP+$dX))
;;
*)
eP=$(($eW+$eT))
;;
esac
eQ=$(($eP-$eW))
if [ $eQ -gt $dX ];then
eO=$(($eW+$dX))
else
eO=$eP
fi
elif [ $eW -ge $eP ];then
break
fi
fi
done
return
}
i(){
g
if [ $eF -eq 0 ];then
if [ "$dZ" = 1 ];then
a "$S"
else
a "$T"
fi
fi
dZ=0
if [ $eF -eq 1 ];then
a "$U"
sleep 10
g
a "$V"
killall -SIGUSR1 telefon
sleep 3
else
rm -f $bL
if [ -x $bU -a -x $bT ];then
sh "$bU" restart 2>&1 >> $bD
a "$W"
else
killall -q -15 telefon && (sleep 3;killall -q -9 telefon)
rm -f /var/run/telefon.pid
/usr/bin/telefon 1 a127.0.0.1 2> /dev/null > "$bR" &
a "$X"
fi
echo date > $bL
sleep 10
if [ -f $aP/restart_telefon ];then
a "$Y"
rm -f $aP/restart_telefon
i
fi
fi
}
j(){
local eZ="$(r $aS)"
local fA=0
if [ -f $aV ];then fA="$(cat $aV)";fi
if [ "$eZ" != "$fA" ];then
a "$R"
a "$Z$fA"
a "$AA$eZ"
echo -n "$eZ" > $aV
dR=1
else a "$AB"
fi
local fB=0
if [ -f $aX ];then fB="$(cat $aX)";fi
dY="$(wget -qO - "$aF")"
date > $aY
if [ "${dY%GMT}" = "$dY" ];then
a "$AC$dY)"
return 1
fi
if [ "$fB" = "$dY" ];then
a "$AD"
local fC="$(s "$fB")"
a "$AE$fC"
if [ "$dR" = 1 ];then
a "$AF"
dR=0
return
fi
if [ $dS -gt 0 ];then
a "$dS$AG"
return
fi
return 1;
else a "$AH$dY > $fB"
fi
return
}
k(){
local w="$(($dU+$dT))"
dT=0
h $w $dV 1
}
l(){
local fD="$(cat $aS)"
a "$AI${#fD}$H"
fD="$(echo -n "$fD" | sed -e 's, ,%20,g')"
fE="$(echo "$VERSION" | tr ' ' '_')"
rm -f $aR
a "$AJ$aD$AK${#fD}$H"
local dL="$(wget -qO "$aR" "$aL?PROXY=1&UPDATERT=Fritzbox&UPDATERV=$fE&Download_LCR=bin&TAKE_FILE=QUERY&$fD" 2>&1)"
if [ -n "$dL" -o ! -f $aR ];then
a "$AL"
if [ -n "$dL" ];then
a "$AM$dL"
else
a "$AN"
fi
return 1
fi
local fF="$(q $aR)"
a "$AO$fF$H"
local t="$(echo -e "\002\231")"
local fG=/var/tmp/tsb/data/lcr.test
local fH=/var/tmp/tsb/data/lcr.cmp
cat $aR | tr '\000' '\231' > $fG
echo -e "\002\231" > /var/tmp/tsb/data/lcr.cmp
local fI="$(cmp $fG $fH)"
rm -f $fH
if [ "${fI#* char 3, line 1}" = "$fI" ];then
a "$AP";
a "$(cat $fG)"
rm -f $fG
return 1
fi;
rm -f $fG
if [ $fF -lt $cK ];then
a "$AQ$fF$AR$cK$AS"
return 1
fi
if [ "$dY" != 0 ];then
echo -n "$dY" > $aX
unset $dY
else
a "$AT$aX"
rm -f $aX
fi
local dL="$(wget -qO "$bA" "$aG" 2>&1)"
if [ -f $bA ];then
local fJ=$dU
dU="$(cat $bA)"
if [ "$dU" != "$fJ" ];then
dT="$(u $dU 3600)"
fi
else
dU=$dW
fi
if [ $dU -le 3000 ];then
dU="$(u)"
fi
local dL="$(wget -qO "$bB" "$aH" 2>&1)"
local fK="${fD#*VORWAHL%26}"
if [ "$fK" != "$fD" ];then
fK="${fK%%\%26*}"
echo -n "$fK" > $aT
else
rm -f $aT
fi
local fL="${fD#*AMT%26}"
if [ "$fL" != "$fD" ];then
fL="${fL%%\%26*}"
echo -n "$fL" > $aU
else
rm -f $aU
fi
return 0
}
m(){
local fM="$(cmp $aR /var/flash/fx_lcr)"
if [ -z "$fM" ];then
a "$AU"
a "$AV";
p $aZ "$(date) U0" $cJ
c
return
fi
local fN=0
d
while true;do
if [ -f $bN ];then
if [ "$fN" = 0 ];then
fN=1
a "$AW"
fi
sleep 2;
else
sleep 2;
if [ ! -f $bN ];then
a "$AX";
cat $aR > /var/flash/fx_lcr
i
p $aZ "$(date) U1" $cJ
break
fi
fi
g
done
c
return
}
n(){
if [ ! -f $aS ];then
if [ "$eA" = 0 ];then
a "$AY$aS)"
fi
fO=2
return 2
fi
local fP=0
a "$AZ$aD"
while !(ping -c 1 "$aD");do
fP="$(($fP+1))"
local fQ=30
if [ $fP -gt 3 ];then
fQ=120
if [ $fP -gt 6 ];then
fQ=600
fi
if [ $fP -gt 10 ];then
fQ=3600
fP=10
fi
fi
a "$AZ$aD$BA$fP$BB$fQ$BC"
if [ "$dZ" = 1 ];then
a "$BD"
i
fi
sleep $fQ
g
done
if j;then
if l;then
m
else
a "$BE";
fO=1;
return 1
fi
fi
fO=0
return
}
fR=4
if [ $eF -eq 0 ];then
while true;do
sleep 2;
if [ -p "$bR" ];then
break
fi
a "$BF"
done
fi
dU="$(cat $bA)"
f
while true;do
a "$BG"
eA=0
while true;do
fO=0
fS=0
n
if [ "$fO" = 1 ];then
if [ -f $bD ];then
cp $bD $bG
date > $bH
fi
dS=$(($dS+1))
a "$BH"
fQ=$dU
a "$BI$fQ$BJ"
h $fQ $dV
rm -f $bD
elif [ "$fO" = 2 ];then
if [ "$dZ" = 1 ];then
i
fi
c
if [ "$eA" = 0 ];then
a "$BK"
eA=1
fi
sleep 10
g
else
a "$BL"
break
fi
done
c
dS=0
if [ "$dZ" = 1 ];then
i
fi
a "$BM"
date > $bI
k
rm -f $bD
done
TSBEOF
cat > /var/tmp/tsb/tsbtools.sh <<'TSBEOF'
#!/bin/sh
o(){ dL="$*";date="$(date "+%d.%m.%y %H:%M:%S")"; echo "- $date: $dL" >> $bE; }
p(){
local fT="$1"
local fU="$2"
local fV="$3"
if [ "$fV" -gt 0 ];then
local fW=0
if [ -f $fT.cnt ];then
fW="$(cat $fT.cnt)"
fi
fW=$(($fW+1))
echo -n $fW > $fT.cnt
if [ $fW -gt "$fV" ];then
cat $fT | sed "$fV,\$ d" > $fT
echo -n $fV > $fT.cnt
fi
fi
if [ -f $fT ];then
echo "$fU$N$(cat $fT)" > $fT
else
echo "$fU" > $fT
fi
}
q(){
local fT="$1"
local fF="$(ls -l "$fT" | tr -s \ )"
fF="${fF#* * * * }"; fF="${fF%% *}"
echo -n "$fF"
}
r(){
local fT="$1"
local date="$(ls -le "$fT" | tr -s \ )"
date="${date#* * * * * }"; date="${date% /*}"; date="${date% * * * * *}"
fX="${date##* }"
date="${date% *}"
echo -n "$date CET $fX"
}
s(){
local fY="$1"
echo -n "$fY" | sed -n 's/^\([A-z][A-z]*\), \([0-9][0-9]*\) \([A-z][A-z]*\) \([0-9][0-9]*\) \([0-9][0-9:]*\) GMT$/\1 \3 \2 \5 GMT \4/p'
}
t(){
local fZ="$1"
local R=""
while [ -z "$R" ];do
R="$(sed -n "s/[^0-9]//g; /^.\{1,$fZ\}/ { s/^\(.\{1,$fZ\}\).*$/\1/; s/^00*//; p; q }" </dev/urandom)"
done
echo -n "$R"
}
u(){
local gA="$1"
local gB="$2"
test -z "$gA" && gA=20000
test -z "$gB" && gB=10000
local gC=$(($gB+500))
if [ $gC -ge $gA ];then
gB=$(($gA/2))
fi
gA=$(($gA-$gB))
local fZ=${#gA}
local gD="$(t $fZ)"
while [ $gD -gt $gA ];do
gE="$(t $fZ)"
if [ $gD -gt $gE ];then
gD=$(($gD-$gE))
else
gD=$(($gE-$gD))
fi
done
gD=$(($gD+$gB))
echo -n "$gD"
}
v(){
local gF="$1"
local fT="$2"
local dL="$(wget -qO $fT "$gF" 2>&1)"
if [ -n "$dL" -o ! -f $fT ];then
echo "$BN$dL"
return 1
fi
return 0
}
w(){
local key="$1"
local gG="${gJ#*&$key=}"
if [ "$gG" != "$gJ" ];then
echo -n "${gG%%&*}"
else
gG="${gJ#$key=}"
[ "$gG" != "$gJ" ] && echo -n "${gG%%&*}"
fi
}
x(){
local key="$1"
local gG="${HTTP_COOKIE#*[&=]$key:}"
[ "$gG" != "$HTTP_COOKIE" ] && echo -n "${gG%%[;&]*}"
}
y(){
echo -ne "$1"
}
z(){
echo "$1" | tr ':&\n=;' '.'
}
aa(){
echo "$1" | tr '\n' '.'
}
ab(){
echo -n "$(ac "$(w "$1")")"
}
e(){
echo -ne "\\$1"
}
ac(){
local eH="%00$(echo -n "$1" | tr '+' ' ')"
local eK="$IFS" gH="" gI=""
export IFS='%'
for gH in $eH;do
gI="${gH%${gH#??}}"; gH="${gH#$gI}"
echo -n "$(case $gI in 00);;09)e 11;;0A)e 12;;0D)e 15;;20)e 40;;21)e 41;;22)e 42;;23)e 43;;24)e 44;;25)e 45;;26)e 46;;27)e 47;;28)e 50;;29)e 51;;2A)e 52;;2B)e 53;;2C)e 54;;2D)e 55;;2E)e 56;;2F)e 57;;3A)e 72;;3B)e 73;;3C)e 74;;3D)e 75;;3E)e 76;;3F)e 77;;40)e 100;;7B)e 173;;7C)e 174;;7D)e 175;;7E)e 176;;7F)e 177;;80)e 200;;81)e 201;;82)e 202;;83)e 203;;84)e 204;;85)e 205;;86)e 206;;87)e 207;;88)e 210;;89)e 211;;8A)e 212;;8B)e 213;;8C)e 214;;8D)e 215;;8E)e 216;;8F)e 217;;90)e 220;;91)e 221;;92)e 222;;93)e 223;;94)e 224;;95)e 225;;96)e 226;;97)e 227;;98)e 230;;99)e 231;;9A)e 232;;9B)e 233;;9C)e 234;;9D)e 235;;9E)e 236;;9F)e 237;;A0)e 240;;A1)e 241;;A2)e 242;;A3)e 243;;A4)e 244;;A5)e 245;;A6)e 246;;A7)e 247;;A8)e 250;;A9)e 251;;AA)e 252;;AB)e 253;;AC)e 254;;AD)e 255;;AE)e 256;;AF)e 257;;B0)e 260;;B1)e 261;;B2)e 262;;B3)e 263;;B4)e 264;;B5)e 265;;B6)e 266;;B7)e 267;;B8)e 270;;B9)e 271;;BA)e 272;;BB)e 273;;BC)e 274;;BD)e 275;;BE)e 276;;BF)e 277;;C0)e 300;;C1)e 301;;C2)e 302;;C3)e 303;;C4)e 304;;C5)e 305;;C6)e 306;;C7)e 307;;C8)e 310;;C9)e 311;;CA)e 312;;CB)e 313;;CC)e 314;;CD)e 315;;CE)e 316;;CF)e 317;;D0)e 320;;D1)e 321;;D2)e 322;;D3)e 323;;D4)e 324;;D5)e 325;;D6)e 326;;D7)e 327;;D8)e 330;;D9)e 331;;DA)e 332;;DB)e 333;;DC)e 334;;DD)e 335;;DE)e 336;;DF)e 337;;E0)e 340;;E1)e 341;;E2)e 342;;E3)e 343;;E4)e 344;;E5)e 345;;E6)e 346;;E7)e 347;;E8)e 350;;E9)e 351;;EA)e 352;;EB)e 353;;EC)e 354;;ED)e 355;;EE)e 356;;EF)e 357;;F0)e 360;;F1)e 361;;F2)e 362;;F3)e 363;;F4)e 364;;F5)e 365;;F6)e 366;;F7)e 367;;F8)e 370;;F9)e 371;;FA)e 372;;FB)e 373;;FC)e 374;;FD)e 375;;FE)e 376;;FF)e 377;;01)e 1;;02)e 2;;03)e 3;;04)e 4;;05)e 5;;06)e 6;;07)e 7;;08)e 10;;0B)e 13;;0C)e 14;;0E)e 16;;0F)e 17;;10)e 20;;11)e 21;;12)e 22;;13)e 23;;14)e 24;;15)e 25;;16)e 26;;17)e 27;;18)e 30;;19)e 31;;1A)e 32;;1B)e 33;;1C)e 34;;1D)e 35;;1E)e 36;;1F)e 37;;esac)$gH"
done
export IFS="$eK"
}
TSBEOF
cat > $basecgi/tsb/2TSB.inc <<'TSBEOF'
if [ -f $aS ];then
gK="$(cat $aS)"
dL="$BO"
else
dL="$BP"
gK=""
fi
id="$(sed -n 's/[^A-Za-z0-9]//g; /^........../ { s/^\(..........\).*$/\1/; p; q }' </dev/urandom)"
echo "$id" > $bQ
gL=""
. $dD
. $dF
echo -e "$BQ$cL$BR$gM$BS$dL$BT$cU$BU$id$BV$gK$BW"
TSBEOF
cat > $basecgi/tsb/cgi.inc <<'TSBEOF'
. $dI
gN=/var/html/cgi-bin
if [ ! -d $gN ];then
gN=/usr/www/html/cgi-bin
fi
gO="webcm"
ad(){
cd $gN
local gP="$1"
echo -n "$gP" |
REQUEST_METHOD="POST" \
REMOTE_ADDR="127.0.0.1" \
CONTENT_TYPE="application/x-www-form-urlencoded" \
CONTENT_LENGTH=${#gP} \
$gN/$gO
}
ae(){
cd $gN
REQUEST_METHOD="GET" REMOTE_ADDR="127.0.0.1" QUERY_STRING="$1" $gN/$gO </dev/null
}
af(){
local gQ="$(ah)"
test -z "$gQ" && return 0
ag "$gQ"
}
ag(){
local gR="$(ad "login:command/password=$(y "$1")")"
test -z "${gR#*$N$N}" -o -z "${gR#*password*}" && return 1
return 0
}
ah(){
allcfgconv -C ar7 -c -o - </dev/null | sed -ne '/^webui[[:space:]]*{/,/^}/ s/[[:space:]]*password[[:space:]]*=[[:space:]]*"\([^"]*\)";.*/\1/p'
}
TSBEOF
cat > $basecgi/tsb/codec.inc <<'TSBEOF'
gS="$(cat /var/flash/voip.cfg | sed -ne 's,[[:space:]]*\(use_audiocodecs\|audiocodecs\)[[:space:]]*=[[:space:]]*\(.*\);,<tr><th>\1</th><td>\2</td></tr>,p')"
gL="$BX"
. $dD
. $dF
echo -e "$BY$gT$BZ$gS$CA$gU$CB"
TSBEOF
cat > $basecgi/tsb/frame_menu.inc <<'TSBEOF'
gV="$CC$cV$gT$CD"main">Wahltabelle</a></div></li>"
gL="$gX"
. $dD
if [ "$gT" != "" ];then
gW="<li><div class=\"navi-nl\" style=\"background-color:#9DB9D2;border:solid 1px;border-color:#d6e2ed;\"><a href=\"$dA$gT\" target="main">Logout</a></div></li>"
fi
echo -e "$CE$TSBlocalhost$CF$cQ$CG$gT$CH$cT$gT$CI$cX$gT$CJ$gV$CK$cY$gT$CL$cZ$gT$CM$gW$CN"
TSBEOF
cat > $basecgi/tsb/functions.inc <<'TSBEOF'
#!/bin/sh
ai(){
gY=0
gZ=0
if [ -f $aZ ];then
hA=""
local eH="$(cat $aZ)"
local eK="$IFS"
export IFS="$N"
for fU in $eH;do
if [ $gY -eq 0 ];then
hA="$fU"
fi
gY=$(($gY+1))
if [ "${fU}" != "$fU" ];then
gZ=$(($gZ+1))
fi
done
export IFS="$eK"
hA="${hA% U?}"
else
hA="-"
fi
}
TSBEOF
cat > $basecgi/tsb/host.inc <<'TSBEOF'
gL="$CO"
. $dD
. $dF
echo -e "$BY$gT$CP$gU$CQ$TSBlocalhost$CR"
TSBEOF
cat > $basecgi/tsb/htmlbody.inc <<'TSBEOF'
echo -e "$CS$hB$CT$gL$CU$hC$CV"
TSBEOF
cat > $basecgi/tsb/htmlfooter.inc <<'TSBEOF'
echo -e "$CW"
TSBEOF
cat > $basecgi/tsb/htmlhead.inc <<'TSBEOF'
echo -e "$CX"
cat $dE
echo "</head>"
TSBEOF
cat > $basecgi/tsb/index.html <<'TSBEOF'
#!/bin/sh
. /var/tmp/tsb/etc/tsbdaemon.conf
. $dI
. $cN/cgi.inc
SIGNAL(){
rm -f $aP/*.lock
exit
}
trap 'SIGNAL SIGTERM' SIGTERM
if [ "$REQUEST_METHOD" = POST ];then
read gJ
gJ="$(echo "$gJ" | tr -d '\015')"
else
gJ="$QUERY_STRING"
fi
hD="${gJ#*action=}"
if [ "$hD" = "$gJ" ];then
if [ "$1" = saveLCR ];then
hD=saveLCR
else
hD="${gJ%%&*}"
fi
else
hD="${hD%%&*}"
fi
if [ -z "$hD" ];then
hD="$1"
fi
. "$TSBdirCgi/tsb/index.inc"
TSBEOF
cat > $basecgi/tsb/index.inc <<'TSBEOF'
echo -e "$CY"
aj(){
echo -e "$CZ"
}
ak(){
local hE="getpage=../htmltsb/fritzcalls$1.js&errorpage=../htmltsb/fritzcallserror.js"
af && ae "$hE"
}
al(){
if [ "$sessionActive" = 1 ];then
if [ -z "$1" ];then
gU="$(sed -n 's/[^A-Za-z0-9]//g; /^.\{32\}/ { s/^\(.\{32\}\).*$/\1/; p; q }' </dev/urandom)"
else
gU="$1"
fi
if [ "$sessionCookie" = 1 ];then
hF="$(date)"
echo "$DA$gU$DB"
else
echo "$DC"
fi
fi
}
if [ "${VERSION#*Demoversion}" = "$VERSION" ];then
hC="$DD$VERSION$DE"
else
hC="$DF$VERSION$DE"
fi
if [ "$hD" != saveLCR ];then
if [ -f $aP/session.conf ];then
. $aP/session.conf
gU="$(w sid)"
if [ "$sessionActive" = 1 ];then
local hG=0
if [ "$sessionCookie" = 1 -a -z "$gU" ];then
gU="$(x sid)"
if [ "$hD" != showCallings -a "$hD" != main -a "$hD" != userLogin -a "$hD" != login -a "$hD" != showLogDaemon ];then
hH=""
hD=frame
fi
fi
eL="$aQ/$gU"
if [ -z "$gU" -o ! -f "$eL" ];then
hI="$(ah)"
if [ -n "$hI" ];then
hH=login
fi
else
hJ="$(cat "$eL")"
eI="$(date +%s)"
eN="$(($eI-$hJ))"
if [ "$sessionExpire" != 0 -a "$eN" -gt "$sessionExpire" ];then
rm -f "$eL"
hH=login
fi
fi
fi
fi
if [ "$hD" = logout ];then
if [ -n "$gU" ];then
eL="$aQ/$gU"
rm -f "$eL"
fi
hH=login
fi
if [ "$hH" = login -a "$hD" = userLogin ];then
hK=Root
hL="$(w passwd)"
hM=""
hI="$(ah)"
hM="$(y "$hI")"
hN="$(ac "$hL")"
if [ -z "$hM" ];then
hH=frame
elif [ "$hM" != "$hN" ];then
hH=login
else
hH=frame
al
fi
fi
if [ "$hH" = login -a "$hD" != frame_menu ];then
aj
hO="<option>Root</option>"
. $cN/$hH.inc
exit
fi
if [ -n "$gU" ];then
gT="&sid=$gU"
date +%s > "$aQ/$gU"
fi
fi
if [ "$hD" = userSettings ];then
hH="_frame";
hP="$cQ?main$gT"
sessionActive=0
test "$(w sessionActive)" = 1 && sessionActive=1
sessionCookie=0
test "$(w sessionCookie)" = 1 && sessionCookie=1
sessionExpire="$(ab sessionExpire | tr -cd '0-9')"
test -z "$sessionExpire" && sessionExpire=0
sessionExpire=$(($sessionExpire*60))
hQ="sessionActive=$sessionActive;sessionCookie=$sessionCookie;sessionExpire=$sessionExpire"
echo -n "$hQ" > $aP/session.conf
sed -e '/^export TSBsession=/d' $bK > $cE
echo "export TSBsession=\"$hQ\"" >> $cE
cat $cE > $bK
al "$gU"
aj
. $cN/$hH.inc
exit
fi
if [ "$hD" = saveCallings ];then
hR=""
af && ae "getpage=..%2Fhtml%2Fde%2FFRITZ%21Box_Anrufliste.csv"
exit
fi
if [ "$hD" != "${hD#dial}" ];then
if [ "$hD" = dial ];then
hD="$(ab param)"
fi
hS="${hD%_page}"
if [ "$hS" != "$hD" ];then
hD="${hD%_page}"
hS=1
fi
hT="${hD#dial}"; hT="${hT%_*}"
hU="${hD#*_}"
hV="getpage=../htmltsb/fritzcallsdial.js&errorpage=../htmltsb/fritzcallserror.js&telcfg:settings/UseClickToDial=1&telcfg:settings/DialPort=$hT&telcfg:command/Dial=$hU"
if af;then ad "$hV" >> $cN/dial.log;fi
if [ "$hS" = 1 ];then
hH=showCallings
hW=1
hX="iDialNumber=\"$hU\";iDialPort=\"$hT\""
aj
. $cN/$hH.inc
else
echo -e "$DG"
cat "$TSBdirHtml/htmltsb/tel.gif"
fi
exit
fi
if [ "$hD" = saveErrorMessage ];then
if [ -f "$bG" ];then
dL="$(cat "$bG")"
else
dL="Kein Logeintrag vorhanden."
fi
if [ -f "$aR" ];then
hY=$(cat "$aR" | tr '\000' '\231')
hZ="$dL$N$N LCR:$N$hY"
else
hZ="$dL$N$N$DH"
fi
echo -e "$DI${hZ}$DJ"
echo -n "$hZ"
exit
fi
aj
case "$hD" in
frametop)
echo "$(cat $cO/_index.html)"
exit
;;
frame_menu) hH=frame_menu;;
frame)
hH=_frame;
hP="$(ab w redirect)"
test -z "$hP" && hP="$cQ?showCallings$gT"
;;
showCallings) hH=showCallings;;
main) hH=main;;
configdaemon) hH=configdaemon;;
configLcr2TSB) hH=2TSB; gM=$cL;;
manuellUpdate)
hH=showLog
hD=showLogDaemon
iA=Daemon
iB=1
touch $aN/manuellUpdate.tmp
echo "$DK"
sleep 10
;;
saveLCR)
hH=showLog
hD=showLogDaemon
iA=Daemon
iB=1
id="${gJ#ID}"; id="${id%%LCRCONFIG*}";
if [ "$id" = "$gJ" ];then
echo -n "$DL"
exit
else
if [ -f $bQ ];then
iC="$(cat $bQ)"
if [ "$id" != "$iC" ];then
echo -n "$DM"
exit
fi
else
echo -n "$DN"
exit
fi
fi
iD="${gJ#*LCRCONFIG=}"
if [ "$iD" = "$gJ" ];then
echo "$DO"
exit
else
echo -n "ENCODED$iD" > $aS
iE="$(sed -n 's/\(.\{65\}\)/\1:/g;p' $aS)"
iD=""
while true;do
gH="${iE%%:*}"
iE="${iE#$gH:}"
iD="$iD$N#LCR=$gH"
if [ "$gH" = "$iE" -o -z "$iE" ];then
break
fi
done
sed -e '/^#LCR\(=\|_CONFIG=\)/d' $bK > $cE
echo "$iD" >> $cE
cat $cE > $bK
fO="$?"
if [ "$fO" != 0 ];then
echo "$DP$bK ($fO)"
fi
touch $cF
echo -n "$DQ"
echo -n "$aS: ${#iD}$DR$bK$DS"
sleep 10
fi
;;
showLCR)
af && ae "getpage=../htmltsb/fritzlcr.js" >/dev/null
sleep 1
if [ -f /var/lcr.html ];then
cat /var/lcr.html
else
echo "$DT"
fi
exit
;;
showPrice2TSB) hH=2TSB;gM=$cM;;
showLog*)
hH=showLog
iA="${hD#showLog}"
;;
showLastError) hH=showErr;;
showLcrUpdated)
gL="$DU"
. $dD
. $dF
if [ -f $aZ ];then
. $cN/functions.inc
ai
echo "$DV$gT$DW$gY$DX$gZ$DY"
if [ $gY -ge $cJ ];then
echo "$DZ$cJ$EA"
fi
echo "$EB"
echo "$(sed 's,U0,UNein,; s,U1,UJa,; s,^\(.*\) U\(.*\),<tr><td>\1</td><td>\2</td></tr>,' $aZ)"
echo "$EC"
else
echo "$ED"
fi
exit
;;
deleteCallings)
hR="$(ak clear)"
rm -f $cA
rm -f $cB
hH=showCallings
;;
2TSB) hH=2TSB; hP="$iM";;
home) hH=home;;
user) hH=user;;
version) hH=version;;
versionInstall)
gL="$EE"
. $dD
. $dF
echo "<pre>"
iF="$(w type)"
fE="$(w v)"
if [ "${fE#-}" = "$fE" ];then
fE="_$fE"
else
fE=""
fi
[ -n "$iF" ] && iF="_$iF"
fT=$aP/install_$iF$fE.tar
echo "Lade Basis-Packet: ....$iF$fE.tar"
dL="$(v "${aI}$iF$fE.tar" $fT)"
if [ -n "$dL" ];then
echo "$dL"
else
mkdir -p $fT.tmp
tar -C $fT.tmp -xf $fT
rm -f $fT
if [ "$?" != 0 ];then
echo "$EF$br>"
else
killall -q -15 tsbdaemon.sh && (sleep 3;killall -q -9 tsbdaemon.sh)
mv $fT.tmp/var/debug.add /var/debug.add
export TSBupdate=1
$fT.tmp/var/install
if [ "$?" = 1 ];then
echo "$EG$N$N"
/sbin/reboot
else
echo "$EH$N$N$EI"
rm -f /var/debug.add /var/debug.tmp $fT.tmp/var/install
for iN in $fT.tmp/var $fT.tmp;do
test -d $iN && rmdir $iN
done
fi
fi
fi
exit
;;
intervall) hH=intervall;;
intervallSet)
hH=main
iF="$(w iType)"
if [ "${iF#[1234]}" != "" ];then
iF=1
fi
iG="$(ab iTimer | tr -cd '0-9')"
test -z "$iG" && iG=12
iH=",$(ab iHours),"
iH="$(echo -n "$iH" | tr -cd '0-9,' | sed -e 's/,0*/,/g')"
test -z "$iH" && iH=4
hQ="iType=$iF;iTimer=$iG;iHours=$iH"
echo -n "$hQ" > $cD
sed -e '/^export TSBintervall=/d' $bK > $cE
echo "export TSBintervall=\"$hQ\"" >> $cE
cat $cE > $bK
;;
host) hH=host;;
hostSet)
hH=main
iI="$(ab host | tr -cd 'A-Za-z_\.\-0-9:/')"
if [ "$iI" != "" -a "$iI" = "${iI#http://}" ];then
iI="http://$iI"
fi
hQ=""
if [ -r $aC ];then
hQ="$(sed -e '/^TSBlocalhost=/d' $aC)$N"
fi
hQ="${hQ}TSBlocalhost=\"$iI\""
echo -n "$hQ" > $aC
sed -e '/^export TSBlocalhost=/d' $bK > $cE
echo "export TSBlocalhost=\"$iI\"" >> $cE
cat $cE > $bK
;;
codec) hH=codec;;
codecSet)
hH=main
if [ -z "$(w codecSet)" ];then
iJ="no"
gS='"PCMA", "PCMU", "G726-32"'
else
iJ="yes"
gS=""
for i in 1 2 3 4 5 6 7 8 9;do
iK="$(w codec$i)"
if [ -n "$iK" ];then
[ -n "$gS" ] && gS="$gS, "
gS="$gS\"$iK\""
fi
done
fi
cat /var/flash/voip.cfg | sed -e "/use_audiocodecs/s#=.*#= $iJ;#" | sed -e "/^[ ]*audiocodecs/s#=.*#= $gS;#" > /var/flash/voip.cfg
/bin/voipd -s 2> /dev/null
sleep 1
/bin/voipd -i 0 2> /dev/null
iL="<p><b>Aktion wurde ausgeführt:</b></p><table cellspacing=\"1\" cellpadding=\"5\" border=\"0\" class=\"tborder2\"><tr><td><pre>Setze Werte:${N}use_audiocodec=$iJ;${N}audiocodec=$gS;${N}${N}VoIP-Dienst wurde neu gestartet</pre></td></tr></table>"
;;
*) hH=_frame; hP="$cQ?showCallings$gT";;
esac
. $cN/$hH.inc
TSBEOF
cat > $basecgi/tsb/intervall.inc <<'TSBEOF'
test -f $cD && . $cD
iHours="$(echo "$iHours" | sed -e 's/^,//; s/,$//')"
test -z "$iTimer" && iTimer="12"
test -z "$iHours" && iHours="7,15,21"
test -z "$iType" && iType=1
eval s$iType=\' checked\'
gL="$EJ"
. $dD
. $dF
echo -e "$BY$gT$EK$gU$EL$iO$s1$EM$iP$s2$EN$iTimer$EO$sessionCookie$s3$EP$iHours$EQ$iP$s4$ER"
TSBEOF
cat > $basecgi/tsb/login.inc <<'TSBEOF'
gL="$ES"
hB=" onload=\"document.TSB.passwd.focus()\""
. $dD
. $dF
echo "$ET$hO$EU"
TSBEOF
cat > $basecgi/tsb/main.inc <<'TSBEOF'
. $cN/functions.inc
am(){
local iQ="$(ps)"
[ -z "${iQ##*tsbdaemon.sh*}" ] && return 0
return 1
}
if [ ! -f $bV ];then
if [ -f $bJ ];then
iR=$(cat $bJ)
! am && iR="$EV"
if [ -f $bM ];then
if [ -f $bN ];then
iS=Ja
else
iS=Nein
fi
else
if [ -f $bL ];then
iS="$EW"
else
iS="$EX"
fi
fi
else
iR="$EY"
iS="$EZ"
fi
if [ -n "$iS" ];then
iS="$FA$iS$FB"
fi
else
if [ -f $bJ ];then
iR=$(cat $bJ)
else
iR="$EY"
fi
fi
if [ -f $bI ];then
iT="$(cat $bI)"
else
iT="$FC"
fi
if [ -f $bH ];then
iU="$(cat $bH)"
iU="$FD$gT\">$iU$DE"
else
iU=-
fi
if [ -f $aX ];then
iV="$(cat $aX)"
iV="$(s "$iV")"
else
iV=-
fi
if [ -f $aY ];then
iW="$(cat $aY)"
else
iW=-
fi
ai
hA="$FE$gT\">$hA$FF$gY$FG$gZ$FH"
if [ ! -f $aS ];then
iX="$FI"
fi
if [ -f $bB ];then
iY="$(cat $bB)"
iZ="${iY#VERSION='}"
if [ "$iZ" != "$iY" ];then
jA="${iZ#*VINFO=\'}"
if [ "$jA" != "$iZ" ];then
jA="${jA%%\'*}"
else
jA=""
fi
iZ="${iZ%%\'*}"
jB="$(echo -n "$iZ" | tr -cd '0-9')"
jC="${VERSION%% *}"
jC="$(echo -n "$jC" | tr -cd '0-9')"
[ "$jB" -lt 10000 ] && jB="${jB}00"
[ "$jC" -lt 10000 ] && jC="${jC}00"
if [ "$jB" -gt "$jC" ];then
iZ="$FJ$iZ$FB"
if [ -n "$jA" ];then
jA="$FK$jA$FB"
fi
else
jA=""
iZ=""
fi
else
iZ=""
fi
jD="${iY#*<<}"
jD="${jD%>>*}"
if [ "$iY" != "$jD" -a -n "$jD" ];then
iY="$FL$jD$FM"
else
iY=""
fi
fi
if [ -f /usr/bin/uptime ];then
dL="$(uptime)"
eW="${dL%%,*}"
jE="${dL#*,}"
if [ -f /proc/uptime ];then
jF="$(cat /proc/uptime | tr -d '.')"
jG="${jF% *}"
jH="${jF#* }"
if [ $jG -gt 1000 ];then
jG=$(($jG/100))
test $jG -gt 0 && jI=$(($jH/$jG))
else
jH=$((100*$jH))
test $jG -gt 0 && jI=$(($jH/$jG))
fi
jJ=$((100-$jI));
test $jI -lt 10 && jI="0$jI"
test $jJ -lt 10 && jJ="0$jJ"
fi
jK="$FN${dK}$FO$qN${qN}$FP$qN${qN}$FQ$qN${qN}$FR${dK}$FS"
jK="$jK$eW$FT$jE$FU$jJ$FV$jI$FW"
fi
eW=$(date)
gL="$FX"
. $dD
. $dF
echo -e "$iL$FY$gT$FZ$gT$GA$gT$GB$gT$GC$gT$GD$iX$GE$dC$gT$GF$iS$GG$iV$GH$iW$GI$hA$GJ$eW$GK$iR$GL$iU$GM$jK $iZ $jA$GN$iY"
. $dG
TSBEOF
cat > $basecgi/tsb/showCallings.inc <<'TSBEOF'
. $dJ
. $dH
eH=""
if [ ! -f $bY -a -f $cA ];then
if [ -f $bV -a "$hW" != 1 ];then
ap 1 M
if [ -f $bW -o -f $bZ ];then
jL="$GO"
fi
fi
if [ -f $cA ];then
eH="$(cat $cA)"
fi
fi
if [ -z "$eH" ];then
if [ -f $bV ];then
ao
else
iG="$GP"
if [ -f $bZ ];then
eV="$(cat $bZ)"
jM="$(date +%s)"
iG="$(($jM-$eV))"
iG="$GQ$iG$GR"
fi
jL="$GS$iG$GT"
fi
fi
if [ -f $TSBdirCgi/callings_message.error -a -r $TSBdirCgi/callings_message.error ];then
jL="<p><b>Fehlermeldung: $(cat $TSBdirCgi/callings_message.error)</b></p>"
fi
if [ -z "$eH" ];then
if [ -f $cB ];then
eH="$(cat $cB)"
else
echo "$GU$jL$GV"
exit
fi
fi
if [ -f $aT -a -r $aT ];then
fK="$(cat $aT)"
fi
if [ -f $aU -a -r $aU ];then
fL="$(cat $aU)"
fi
echo -e "$CX"
cat $cO/show_callings.css
echo -e "$GW$eH$GX$hX$GY$fK$GZ$fL$HA$jL$HB$gT$HC$gU$HD"
TSBEOF
cat > $basecgi/tsb/showErr.inc <<'TSBEOF'
if [ -f $bG ];then
hZ="$(cat $bG)"
else
hZ="$HE"
fi
gL="$HF"
. "$dD"
. "$dF"
echo "$HG$gT$HH$hZ$HI"
TSBEOF
cat > $basecgi/tsb/showLog.inc <<'TSBEOF'
jN="$HJ"
jO="$HK"
jP="$HL"
jQ="$HM"
jR="$HN"
jS="$HO$jN$HP$gT$HQ"
jT="$HO$jO$HR$gT$HQ"
jU="$HO$jP$HS$gT$HQ"
jV="$HO$jQ$HT$gT$HU"
if [ -f $bE ];then
jW="$HO$jR$HV$gT$HW"
fi
jX="$HX"
tr="$HY"
jY="$FB"
jZ="$EC"
if [ "$iA" = Daemon ];then
kA="$jN"
jS=""
if [ -f $bD ];then
hZ="$(cat $bD)"
else
hZ="$HE"
fi
if [ "$iB" = 1 ];then
hZ="$hZ$HZ$gT$IA"
fi
hZ="$jX$tr<ul>$hZ</ul>$jY$jZ"
else
if [ "$iA" = Monitor ];then
kA="$jO"
jT=""
if [ -f $bO.start ];then
hZ="$(cat $bO.start)"
else
hZ="$HE"
fi
hZ="$jX$tr<ul>$hZ</ul>$jY$jZ"
else
if [ "$iA" = Install ];then
kA="$jP"
jU=""
if [ -f $bF ];then
hZ="$(cat $bF)"
else
hZ="$HE"
fi
hZ="$jX$tr<ul>$hZ</ul>$jY$jZ"
elif [ "$iA" = WebLog ];then
kA="$jR"
jU=""
if [ -f $bE ];then
hZ="$(cat $bE)"
else
hZ="$IB"
fi
hZ="$jX$tr<pre>$hZ</pre>$jY$jZ"
else
if [ "$iA" = System ];then
kA="$jQ"
jV=""
hZ="$IC$jX"
if [ -f /proc/version ];then
hZ="$hZ$(cat /proc/version | sed -ne 's,\(.*\) version\(.*\) (.*) (\(.*\)version\(.*\))\(.*#.*\) \([A-Z][a-z]* [A-Z][^A-Z0-9]* [0-9].*\),<tr><th>Kernel Version:</th><td>\1 \2</td></tr><tr><th>Kernel compiliert mit:</th><td>\3\4\5</td></tr><tr><th>Kernel erstellt am</th><td>\6</td></tr>,p')"
fi
if [ -f /bin/run_clock ];then
hZ="$hZ<tr><th>Gesamtlaufzeit der Fritz!Box</th><td>$(/bin/run_clock | sed -ne 's,[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\).*,\4 Jahre \3 Monate \2 Tage \1 Stunden (\5 Neustarts),p')</td></tr>"
fi
if [ -f "/proc/avalanche/env" ];then
kB="$(cat /proc/avalanche/env | sed -n 's,^\(bootloaderVersion\|firmware_version\|HWRevision\|ProductID\|annex\|cpufrequency\|firmware_info\|sysfrequency\|usb_manufacturer_name\|usb_device_name\)\([[:space:]]*\)\(.*\),<tr><th>\1:</th><td>\3</td></tr>,p')"
hZ="$hZ$kB"
fi
if [ -f /proc/self/environ ];then
kB="$(cat /proc/self/environ | tr '\000' '\12' | sed -n 's,^\(CONFIG_[^=]*\|DISABLE_[^=]\|Country\|Language\|HWRevision\|HWSubRevision\|OEM\)=\(.*\),<tr><th>\1:</th><td>\2</td></tr>,p')"
hZ="$hZ$kB"
fi
hZ="$hZ$jZ"
if [ -f /proc/meminfo ];then
kB="$(cat /proc/meminfo)"
hZ="$hZ$ID$jX$tr$IE$kB$IF$jY$jZ"
fi
if [ -f /proc/cpuinfo ];then
kB="$(cat /proc/cpuinfo)"
hZ="$hZ$IG$jX$tr$IE$kB$IF$jY$jZ"
fi
if [ -c /var/flash/voip.cfg -a -r /var/flash/voip.cfg ];then
kB="$(cat /var/flash/voip.cfg 2>/dev/null | sed '/username/d;/passwd/d;/[[:space:]]*\/\//d')"
[ -n "$kB" ] && hZ="$hZ$IH$jX$tr$IE$kB$IF$jY$jZ"
fi
fi
fi
fi
fi
if [ -f $bV ];then
jT=""
fi
gL="$HF"
. $dD
. $dF
echo "$HO$kA$II$hD$gT$IJ"
echo "$hZ"
echo "$jS$jT$jU$jV$jW</body></html>"
TSBEOF
cat > $basecgi/tsb/updateCallings.inc <<'TSBEOF'
. /var/tmp/tsb/etc/tsbdaemon.conf
. $dJ
ak(){
af && ae "getpage=../htmltsb/fritzcalls$1.js"
}
an(){
local kC="$1"
echo -n '<? query telcfg:settings/RefreshJournal ?>#<? multiquery telcfg:settings/Journal/listwindow(0,'$kC',Type,Date,Number,Port,Duration,Route,RouteType,Name) `$2;$3;$4;$5;$6;$7;$8;$9#` ?>' > $cO/fritzcalls2M.js
af && ae "getpage=../htmltsb/fritzcalls2M.js"
}
ao(){
if [ ! -f $bW -a ! -f $bZ ];then
date +%s > $bW
fi
}
ap(){
local eF="$1"
local kD="$2"
local kE="$CONFIG_PRODUKT_NAME"
if [ "${kE#Eumex}" = "$kE" ];then
kE=""
else
kE="Eumex"
fi
local hR="" eH="" fO=""
if [ -f $bY ];then
if [ "$kD" = M ];then
ao
else
local kF=40
while [ -f $bY ];do
kF=$(($kF-1))
if [ $kF -lt 0 ];then
rm -f $bY
break
fi
sleep 3
done
fi
else
touch $bY
rm -f $TSBdirCgi/callings_message.error
if [ "$eF" = 1 ];then
if [ -f $cA ];then
eH="$(cat $cA)"
local kG="${eH#*var callingsAVM=\"}"
if [ -n "$eH" -a "$kG" != "$eH" ];then
eH="${eH%var callingsAVM=\"*}"
kH="${kG%%#*}"
if [ "$kH" != "$kG" ];then
local kI=0
local entries
for kC in 20 60;do
if [ "$kD" = M -a "$kC" -gt 40 ];then
ao
eH=""
break
fi
local kJ="$(an $kC)"
kJ="${kJ#*#}"
rm -f $bX
if [ -z "$kJ" ];then
kI=1
else
local eK="$IFS"
export IFS="#"
local kK=0
for fU in $kJ;do
if [ "$fU" = "$kH" ];then
kK=1
break
fi
echo -n "$fU#" >> $bX
done
export IFS="$eK"
if [ $kK -eq 1 ];then
kI=1
break
fi
fi
done
if [ $kI -eq 1 ];then
if [ -f $bX ];then
kJ="$(cat $bX)"
eH="${eH}var callingsAVM=\"$kJ$kG"
else
eH="${eH}var callingsAVM=\"$kG"
fi
elif [ "$kD" != M ];then
hR="$(ak ${kE}2N)"
eH=""
fi
else
hR="$(ak ${kE}2N)"
eH=""
fi
else
rm -f $aP/callings.*
ao
hR=""
eH=""
fi
else
hR="$(ak ${kE}2N)"
eH=""
fi
else
hR="$(ak ${kE}2)"
eH=""
fi
if [ -z "$eH" -a -n "$hR" ];then
eH="${hR#*RESULT:}"
if [ ${#eH} -eq ${#hR} ];then
echo -n "$IK" > $TSBdirCgi/callings_message.error
rm -f $cA
fO=1
fi
fi
if [ -z "$fO" -a -n "$eH" ];then
echo -n "$eH" > $cA
echo -n "$eH" > $cB
fi
rm -f $bY
fi
}
TSBEOF
cat > $basecgi/tsb/user.inc <<'TSBEOF'
test "$sessionActive" = 1 && iO="$IL"
test "$sessionCookie" = 1 && iP="$IL"
test -z "$sessionExpire" && sessionExpire=7200
sessionExpire=$(($sessionExpire/60))
gL="$IM"
. $dD
. $dF
echo -e "$BY$gT$IN$gU$IO$iO$IP$iP$IQ$sessionExpire$IR"
TSBEOF
cat > $basecgi/tsb/version.inc <<'TSBEOF'
gL="$IS"
. $dD
. $dF
aq(){
local fT="$1"
eH="$(cat $fT)"
if [ "${eH#VERSIONS:}" = "$eH" ];then
echo "<tr><th>$eH</th></tr>"
else
eH="${eH#VERSIONS:$N}"
eK="$IFS"
export IFS="$N"
for dQ in $eH;do
kL="${dQ%%#*}"
kM="${dQ#$kL#}"
kM="${kM%%#*}"
kB="${dQ#$kL#$kM#}"
echo "$IT$gU$IU$kM&v=$kL$IV${dK}$IW${qN}$IX${qN}$IY$qN$dK$IZ$kL$JA$kB$FB"
done
export IFS="$eK"
fi
}
dL="$(v "$aJ" $bC)"
if [ -z "$dL" ];then
kN="$(aq $bC)"
else
kN="$dL"
fi
echo -e "$BY$gT$JB$kN$JC"
TSBEOF
cat > $basecgi/tsb/_frame.inc <<'TSBEOF'
echo -e "$JD$gT$JE$hP$JF"
TSBEOF
for DIR in /var/tmp/tsb/* $basecgi $basecgi/tsb $basecgi/tsb/*; do
e "chmod 755 $DIR"
done
e "chmod -R 444 $basewww/htmltsb/*"
local error=""
local weberror="$ok"
testWebPages(){
l "Teste Webseiten:"
local msg="$(wget -qO /var/tmp/wgettestpage.tmp http://127.0.0.1/tsb.htm 2>&1)"
if [ -z "$msg" ]; then
msg="OK"
else
if [ "$weberror" -eq 1 ]; then
weberror=2
fi
ok=0
error="Fehler Download tsb.htm Seite ($msg)"
msg="FEHLER: $msg"
fi
l "LCR Updater: wget http://127.0.0.1/tsb.htm : ($msg)"
local msg="$(wget -qO /var/tmp/wgettestpage.tmp http://127.0.0.1/index.html 2>&1)"
if [ -z "$msg" ]; then
msg="OK"
else
ok=0
weberror=3
error="$error; Fehler Download AVM index.html Seite ($msg)"
msg="FEHLER: $msg"
fi
l "AVM: wget http://127.0.0.1/index.html : ($msg)"
rm -f "/var/tmp/wgettestpage.tmp"
}
testWebPages
if [ -z "$TSBupdate" ];then
if [ "$weberror" -eq 2 ]; then
local rootName="${rootDir#/usr/www/}"
l "rootName=$rootName"
if [ "$rootName" = "${rootName#*/}" ]; then
error=""
l "Fehler beim Webroot, versuche weitere Brandings ins Webroot einzubinden..."
for name in `ls /usr/www`; do
local dir="/usr/www/$name"
if [ -d "$dir" ]; then
if [ -z "$name" ] || [ "$name" = "all" ] || [ "$name" = "cgi-bin" ] || [ "$name" = "html" ] || [ "$name" = "$rootName" ]; then
l " - skip $name"
else
l "??? mount -o bind $basewww $dir"
fi
fi
done
testWebPages
else
l "Fehler: rootName enthält Subverzeichnisse!"
fi
fi
if [ "$TSBlocalhost" = "AUTO" ]; then
l "TSBlocalhost=AUTO: Werte ifconfig lan aus"
waitMax=24
while true; do
local ip="$(ifconfig lan | sed -n 's/[[:space:]]*inet addr:\([0-9][0-9\.]*\)[[:space:]]*.*/\1/p')"
if [ -n "$ip" ] || [ $waitMax -le 0 ]; then
break
fi
l "Fehler bei Auswertung von ifconfig ($?), versuche erneut..."
waitMax="$(($waitMax-1))"
sleep 5
done
echo "TSBlocalhost=http://$ip" >> /var/tmp/tsb/etc/user.conf
l "Füge Konfiguration TSBlocalhost=http://$ip hinzu ($(OK))"
elif [ -n "$TSBlocalhost" ]; then
l "TSBlocalhost=$TSBlocalhost"
echo "TSBlocalhost=\"$TSBlocalhost\"" >> /var/tmp/tsb/etc/tsbdaemon.conf
fi
if [ -n "$TSBsession" ]; then
echo -n "$TSBsession" > /var/tmp/tsb/data/session.conf
fi
if [ -n "$TSBintervall" ]; then
echo -n "$TSBintervall" > /var/tmp/tsb/data/intervall.conf
fi
fi
l "LCR Updater eingerichtet"
/bin/update_led_off
l "LED OFF ($(OK))"
killall -q -15 tsbdaemon.sh && (sleep 5;killall -q -9 tsbdaemon.sh)
/var/tmp/tsb/tsbdaemon.sh 2>&1 > /dev/null &
l "Starte tsbdaemon ($(OK))"
local dumpInfos=1
if [ -n "$error" ]; then
l "FEHLER bei Installation der Webseitenstruktur"
l "Fehlermeldungen: $error"
l "FERTIG."
elif [ "$ok" = 1 ]; then
l "Installation war erfolgreich. FERTIG."
dumpInfos=0
else
l "Bei der Installation sind Fehler aufgetreten! FERTIG."
fi
if [ "$dumpInfos" -eq 1 ]; then
l "Informationen, um mögliche Fehlerursachen einzugrenzen:"
l "set:"
l "$(set)"
l "Verzeichnisse:"
l "/var"
l "$(ls -l /var)"
for dir in /usr/www /var/tmp/tsb; do
l "BASEDIR: $dir"
for file in `find $dir -type d`; do
l "DIR: $file"
l "$(ls -l $file)"
done
done
cat $TSBfileLogMsg >/var/lcr.html
echo "Vor Installation:" >>/var/lcr.html
cat $TSBfileLogMsg.dump >>/var/lcr.html
fi
EOF_TSBINSTALLER
chmod 755 /var/tmp/tsbinstaller
/var/tmp/tsbinstaller 2>&1 > /dev/null &
#<<TSB: LCR Updater Installer# Jan 1 02:02:16 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
Jan 1 02:02:16 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.2:53 - Network is unreachable (128)
echo Jan 1 02:02:22 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
""> /Jan 1 02:02:27 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
Jan 1 02:02:27 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.2:53 - Network is unreachable (128)
var/flash/deJan 1 02:02:32 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.1:53 - Network is unreachable (128)
Jan 1 02:02:32 multid[380]: 0.0.0.0:3073: failed to send UDP-datagram to 192.168.180.2:53 - Network is unreachable (128)
bug.cfg
# ^[[A^[[A echo "" > /var/flash/debug.cfg
#