#!/bin/bash tested=0; notempty=0; old=0; maxweeks=29; declare -a week; for i in $(seq 0 $maxweeks); do week[i]=0; done; function logweek() { seconds=$1; weekno=0; while [ $seconds -gt 604800 ] ; do weekno=$[weekno + 1]; seconds=$[seconds - 604800]; done if [ $weekno -gt $maxweeks ]; then weekno=$maxweeks; fi; tmp=${week[$weekno]}; tmp=$[$tmp+1]; week[$weekno]=$tmp; } function sleeponqueuelength() { wget -o /dev/null -O queueinfo http://tah.openstreetmap.org/Request/show/; queuelength=$(grep total queueinfo | cut -d "(" -f 2 | cut -d ")" -f 1 | cut -d " " -f 2); echo "=== $queuelength ==="; if [ -z $queuelength ] ; then sleep 3600; sleeponqueuelength; fi; if [ $queuelength -gt 10000 ] ; then w=$(echo "$queuelength - 10000" | bc -l); sleep $w; fi; } function check() { i=$1; j=$2; cd ~/tilesAtHome/png2tileinfo/; type=$(./png2tileinfo.pl check $i $j | cut -d " " -f 4); cd - > /dev/null; if [ $type == 2 ] ; then return 0; fi wget -o /dev/null -O tileinfo http://server.tah.openstreetmap.org/Browse/details/tile/12/$i/$j/; tested=$[tested + 1]; grep "based on oceantiles.dat" tileinfo > /dev/null; if [ $? == 1 ] ; then notempty=$[notempty + 1]; timestamp=$(date -d $(grep "Last modified" tileinfo | awk '{print $3}') +%s); now=$(date +%s); diff=$[now - timestamp]; logweek $diff; if [ $diff -gt 3628800 ] ; then # 6 weeks old=$[old + 1]; # echo "update $i $j"; wget -o /dev/null -O requestinfo "http://server.tah.openstreetmap.org/Request/create/?x=$i&y=$j&min_z=12&priority=4&src=petschge_oldtiles&layers=1&layers=3"; #cat requestinfo; #echo ""; return 1; fi; fi; return 0; } queuestat=$(date +%s); while true; do x=$[RANDOM / 8]; y=$[RANDOM / 8]; check $x $y; hits=$?; if [ $hits == 1 ]; then l=$[(x + 4096 - 1) % 4096]; r=$[(x + 1) % 4096]; t=$[(y + 4096 - 1) % 4096]; b=$[(y + 1) % 4096]; check $l $t; hits=$[hits + $?]; check $l $y; hits=$[hits + $?]; check $l $b; hits=$[hits + $?]; check $x $t; hits=$[hits + $?]; check $x $b; hits=$[hits + $?]; check $r $t; hits=$[hits + $?]; check $r $y; hits=$[hits + $?]; check $r $b; hits=$[hits + $?]; if [ $hits -ge 5 ]; then ll=$[(x + 4096 - 2) % 4096]; rr=$[(x + 2) % 4096]; tt=$[(y + 4096 - 2) % 4096]; bb=$[(y + 2) % 4096]; check $ll $tt check $ll $t check $ll $y check $ll $b check $ll $bb check $l $tt check $x $tt check $r $tt check $l $bb check $x $bb check $r $bb check $rr $tt check $rr $t check $rr $y check $rr $b check $rr $bb fi; echo "tested: $tested, notempty: $notempty, old: $old"; logfile=$(date +%Y%m%d) echo "" > $logfile; for w in $(seq 0 $maxweeks); do echo "$w ${week[$w]}" >> $logfile; done; now=$(date +%s); elapsed=$(echo "$now - $queuestat" | bc -l); if [ $elapsed -gt 600 ] ; then queuestat=$now; sleeponqueuelength; fi; fi; sleep 1; done