TomatoAnon project
[tomato.git] / release / src / router / others / tomatoanon
blob388b36099ec3197fff2eee2f2aa28f3df81f7693
1 #!/bin/sh
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.
12 # Sended information:
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
21 # That`s all
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
30 #Collect datas
31 MOD=Shibby
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 WANMAC_MD5=`echo "$WANMAC+$LANMAC" | md5sum | cut -d " " -f1`
37 nvram set tomatoanon_id="$WANMAC_MD5"
38 nvram commit
40 #Detect Version and Buildtype
41 KERNEL=`uname -r | cut -d "." -f1,2`
42 if [ "$KERNEL" == "2.6" ]; then
43 IS_USB=`nvram get os_version | grep USB | wc -l`
44 if [ "$IS_USB" == "0" ]; then #if K26
45 VER=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f1,2`
46 BUILDTYPE=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f3,4,5`
47 else #if K26USB
48 VER=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f1,2,3`
49 BUILDTYPE=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f4,5,6`
51 else #K2.4
52 IS_USB=`nvram get os_version | grep USB | wc -l`
53 if [ "$IS_USB" == "0" ]; then #if K24
54 VER=`nvram get os_version | cut -d " " -f2,3`
55 BUILDTYPE=`nvram get os_version | cut -d " " -f4,5`
56 else # if K24USB
57 VER=`nvram get os_version | cut -d " " -f2,3,4`
58 BUILDTYPE=`nvram get os_version | cut -d " " -f5,6`
62 #Get country name and code
63 wget -O /tmp/country http://api.easyjquery.com/test/demo-ip.php
64 ISO=`cat /tmp/country | grep Country] | cut -d " " -f7`
65 COUNTRY=`cat /tmp/country | grep CountryName | cut -d " " -f7`
66 rm /tmp/country
68 #Change all spaces to %20.
69 echo "http://tomato.groov.pl/tomatoanon.php?wanmac_md5=$WANMAC_MD5&model=$MODEL&version=$VER&buildtype=$BUILDTYPE&country=$COUNTRY&flag=$ISO&uptime=$UPTIME&mod=$MOD&anon=1" > /tmp/AnonLink
70 sed -i "s/ /%20/g" /tmp/AnonLink
71 ANONSEND=`cat /tmp/AnonLink`
72 rm /tmp/AnonLink
74 #We have all we need well we can send datas to Anon database
75 wget -O /dev/null $ANONSEND
77 #Thanks
79 INTERVAL=`nvram get tomatoanon_cru`
80 cru d tomatoanon
81 cru a tomatoanon "* */$INTERVAL * * * /usr/bin/tomatoanon"
83 else #if anon is not enabled or was disabled right now
85 ISCRU=`cru l | grep tomatoanon | wc -l`
86 if [ "$ISCRU" == "0" ]; then
87 cru d tomatoanon
90 fi #end ANON_ENABLE
92 else #if answer is not enabled or was disabled right now
94 ISCRU=`cru l | grep tomatoanon | wc -l`
95 if [ "$ISCRU" == "0" ]; then
96 cru d tomatoanon
99 fi #end ANON_ANSWER