3 ###############################
4 # Copyright (C) 2012 shibby
6 # This script send anonymous or incompleted information about model of router and installed tomato version.
7 # Those information will be used ONLY for stats.
8 # Any of private information will be NOT sended!
9 # Results you can explore on http://tomato.groov.pl/tomatoanon.php page.
10 # If you don`t agree to run this script you can set nvram variable tomatoanon to 0.
13 # - MD5SUM of WAN+LAN MAC addresses - this will identify a router. Ex: 1c1dbd4202d794251ec1acf1211bb2c8
14 # - Model of router. Ex: Asus RT-N66U
15 # - Version of installed tomato. Ex: 102 K26 USB
16 # - Builtype. Ex: Mega-VPN-64K
17 # - Country. Ex: POLAND
18 # - ISO Country code. Ex: PL
19 # - Uptime of your router. Ex: 3 days
22 ###############################
24 ANON_ENABLED
=`nvram get tomatoanon_enable`
25 ANON_ANSWER
=`nvram get tomatoanon_answer`
27 if [ "$ANON_ANSWER" == "1" ]; then
28 if [ "$ANON_ENABLED" == "1" ]; then
32 UPTIME
=`uptime | cut -d "," -f1 | cut -d " " -f4,5`
33 WANMAC
=`nvram get wan_hwaddr`
34 LANMAC
=`nvram get lan_hwaddr`
35 MODEL
=`nvram get t_model_name`
36 DRIVER
=`wl ver | grep version | awk '{ print $7 }'`
37 WANMAC_MD5
=`echo "$WANMAC+$LANMAC" | md5sum | awk '{ print $1 }'`
39 ROUTERID
=`nvram get tomatoanon_id`
40 if [ ! "$ROUTERID" == "$WANMAC_MD5" ]; then
41 nvram
set tomatoanon_id
="$WANMAC_MD5"
45 #Detect Version and Buildtype
46 KERNEL
=`uname -r | cut -d "." -f1,2`
47 if [ "$KERNEL" == "2.6" ]; then
48 IS_USB
=`nvram get os_version | grep USB | wc -l`
49 if [ "$IS_USB" == "0" ]; then #if K26
50 VER
=`nvram get os_version | awk '{ print $2" "$3 }' | cut -d "-" -f2`
51 BUILDTYPE
=`nvram get os_version | awk '{ print $4 }'`
53 VER
=`nvram get os_version | awk '{ print $2" "$3" "$4 }' | cut -d "-" -f2`
54 BUILDTYPE
=`nvram get os_version | awk '{ print $5 }'`
57 IS_USB
=`nvram get os_version | grep USB | wc -l`
58 if [ "$IS_USB" == "0" ]; then #if K24
59 VER
=`nvram get os_version | awk '{ print $2" "$3 }'`
60 BUILDTYPE
=`nvram get os_version | awk '{ print $4 }'`
62 VER
=`nvram get os_version | awk '{ print $2" "$3" "$4 }'`
63 BUILDTYPE
=`nvram get os_version | awk '{ print $5 }'`
67 #Get country name and code
68 wget
-O /tmp
/country http
://api.easyjquery.com
/test
/demo-ip.php
69 ISO
=`cat /tmp/country | grep Country] | awk '{ print $3 }'`
70 COUNTRY
=`cat /tmp/country | grep CountryName | awk '{ print $3" "$4" "$5 }'`
73 #Change all spaces to %20.
74 echo "http://tomato.groov.pl/tomatoanon.php?wanmac_md5=$WANMAC_MD5&model=$MODEL&version=$VER&buildtype=$BUILDTYPE&country=$COUNTRY&flag=$ISO&driver=$DRIVER&uptime=$UPTIME&mod=$MOD&anon=1" > /tmp
/AnonLink
75 sed -i "s/ /%20/g" /tmp
/AnonLink
76 ANONSEND
=`cat /tmp/AnonLink`
79 #We have all we need well we can send datas to Anon database
80 wget
-O /dev
/null
$ANONSEND
84 INTERVAL
=`nvram get tomatoanon_cru`
87 MINUTES
=`awk 'BEGIN {srand(); printf "%d", 60*rand()}'`
90 cru a tomatoanon
"$MINUTES */$INTERVAL * * * /usr/sbin/tomatoanon"
92 else #if anon is not enabled or was disabled right now
94 ISCRU
=`cru l | grep tomatoanon | wc -l`
95 if [ "$ISCRU" == "0" ]; then
101 else #if answer is not enabled or was disabled right now
103 ISCRU
=`cru l | grep tomatoanon | wc -l`
104 if [ "$ISCRU" == "0" ]; then