TomatoAnon: Do not commit routerid on every launch
[tomato.git] / release / src / router / others / tomatoanon
blob05bcc24ac4563682d28adf1e4b80adafbd55fbd2
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`
38 ROUTERID=`nvram get tomatoanon_id`
39 if [ ! "$ROUTERID" == "$WANMAC_MD5"]; then
40 nvram set tomatoanon_id="$WANMAC_MD5"
41 nvram commit
44 #Detect Version and Buildtype
45 KERNEL=`uname -r | cut -d "." -f1,2`
46 if [ "$KERNEL" == "2.6" ]; then
47 IS_USB=`nvram get os_version | grep USB | wc -l`
48 if [ "$IS_USB" == "0" ]; then #if K26
49 VER=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f1,2`
50 BUILDTYPE=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f3,4,5`
51 else #if K26USB
52 VER=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f1,2,3`
53 BUILDTYPE=`nvram get os_version | cut -d "-" -f2,3,4,5,6,7,8 | cut -d " " -f4,5,6`
55 else #K2.4
56 IS_USB=`nvram get os_version | grep USB | wc -l`
57 if [ "$IS_USB" == "0" ]; then #if K24
58 VER=`nvram get os_version | cut -d " " -f2,3`
59 BUILDTYPE=`nvram get os_version | cut -d " " -f4,5`
60 else # if K24USB
61 VER=`nvram get os_version | cut -d " " -f2,3,4`
62 BUILDTYPE=`nvram get os_version | cut -d " " -f5,6`
66 #Get country name and code
67 wget -O /tmp/country http://api.easyjquery.com/test/demo-ip.php
68 ISO=`cat /tmp/country | grep Country] | cut -d " " -f7`
69 COUNTRY=`cat /tmp/country | grep CountryName | cut -d " " -f7`
70 rm /tmp/country
72 #Change all spaces to %20.
73 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
74 sed -i "s/ /%20/g" /tmp/AnonLink
75 ANONSEND=`cat /tmp/AnonLink`
76 rm /tmp/AnonLink
78 #We have all we need well we can send datas to Anon database
79 wget -O /dev/null $ANONSEND
81 #Thanks
83 INTERVAL=`nvram get tomatoanon_cru`
84 cru d tomatoanon
85 cru a tomatoanon "* */$INTERVAL * * * /usr/bin/tomatoanon"
87 else #if anon is not enabled or was disabled right now
89 ISCRU=`cru l | grep tomatoanon | wc -l`
90 if [ "$ISCRU" == "0" ]; then
91 cru d tomatoanon
94 fi #end ANON_ENABLE
96 else #if answer is not enabled or was disabled right now
98 ISCRU=`cru l | grep tomatoanon | wc -l`
99 if [ "$ISCRU" == "0" ]; then
100 cru d tomatoanon
103 fi #end ANON_ANSWER