3 ###############################
4 # Copyright (C) 2012/2013 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://anon.groov.pl page.
10 # If you don`t agree to run this script you can disable it in GUI.
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: 110 K26 USB
16 # - Builtype. Ex: Mega-VPN-64K
17 # - Uptime of your router. Ex: 3 days
18 # - Number of version for tomato update notification system. Ex: 110
21 ###############################
23 ANON_ENABLED
=`nvram get tomatoanon_enable`
24 ANON_ANSWER
=`nvram get tomatoanon_answer`
25 ANON_NOTIFY
=`nvram get tomatoanon_notify`
27 if [ "$ANON_ANSWER" == "1" ]; then
28 if [ "$ANON_ENABLED" == "1" ]; then
30 ############################
32 ############################
34 #Detect Version and Buildtype
35 KERNEL
=`uname -r | cut -d "." -f1,2`
36 if [ "$KERNEL" == "2.6" ]; then
37 IS_USB
=`nvram get os_version | grep USB | wc -l`
38 if [ "$IS_USB" == "0" ]; then #if K26
39 VER
=`nvram get os_version | awk '{ print $2" "$3 }' | cut -d "-" -f2`
40 BUILDTYPE
=`nvram get os_version | awk '{ print $4 }'`
42 VER
=`nvram get os_version | awk '{ print $2" "$3" "$4 }' | cut -d "-" -f2`
43 BUILDTYPE
=`nvram get os_version | awk '{ print $5 }'`
46 IS_USB
=`nvram get os_version | grep USB | wc -l`
47 if [ "$IS_USB" == "0" ]; then #if K24
48 VER
=`nvram get os_version | awk '{ print $2" "$3 }'`
49 BUILDTYPE
=`nvram get os_version | awk '{ print $4 }'`
51 VER
=`nvram get os_version | awk '{ print $2" "$3" "$4 }'`
52 BUILDTYPE
=`nvram get os_version | awk '{ print $5 }'`
56 if [ "$1" == "checkver" -a "$ANON_NOTIFY" == "1" ]; then
57 # Tomato Update Notification Script
58 # This works only for Shibby`s builds !!!
59 CHECK_VER
=`echo $VER | awk '{print $1}' | cut -d "." -f1 | sed 's/[^0-9]*//g`
61 #Change all spaces to %20
62 echo "http://anon.groov.pl/index.php?v=$CHECK_VER&mod=$MOD&anon=2" > /tmp
/AnonLink
63 sed -i "s/ /%20/g" /tmp
/AnonLink
64 ANONSEND
=`cat /tmp/AnonLink`
67 RESULT
="/tmp/anon.version"
68 wget
-O $RESULT $ANONSEND
70 #do we have result? If don`t, then set no update needed
71 if [ ! -f "$RESULT" ]; then
72 echo "have_update=no" > $RESULT
75 #Thanks. Now add cron job
77 ISCRU
=`cru l | grep checkver | wc -l`
78 if [ "$ISCRU" == "0" ]; then
81 MINUTES
=`awk 'BEGIN {srand(); printf "%d", 60*rand()}'`
84 HOUR
=`awk 'BEGIN {srand(); printf "%d", 23*rand()}'`
87 cru a checkver
"$MINUTES $HOUR * * * /usr/sbin/tomatoanon checkver"
90 else #just update anon database
93 UPTIME
=`uptime | cut -d "," -f1 | cut -d " " -f4,5`
94 WANMAC
=`nvram get wan_hwaddr`
95 LANMAC
=`nvram get lan_hwaddr`
96 MODEL
=`nvram get t_model_name`
97 DRIVER
=`wl ver | grep version | awk '{ print $7 }'`
98 WANMAC_MD5
=`echo "$WANMAC+$LANMAC" | md5sum | awk '{ print $1 }'`
100 ROUTERID
=`nvram get tomatoanon_id`
101 if [ ! "$ROUTERID" == "$WANMAC_MD5" ]; then
102 nvram
set tomatoanon_id
="$WANMAC_MD5"
106 #Change all spaces to %20.
107 echo "http://anon.groov.pl/index.php?wanmac_md5=$WANMAC_MD5&model=$MODEL&version=$VER&buildtype=$BUILDTYPE&driver=$DRIVER&uptime=$UPTIME&mod=$MOD&anon=1" > /tmp
/AnonLink
108 sed -i "s/ /%20/g" /tmp
/AnonLink
109 ANONSEND
=`cat /tmp/AnonLink`
112 #We have all we need well we can send datas to Anon database
113 RESULT
="/tmp/anon.result"
114 wget
-O $RESULT $ANONSEND
116 #Thanks. Now add cron job
118 ISCRU
=`cru l | grep anonupdate | wc -l`
119 if [ "$ISCRU" == "0" ]; then
121 #random minutes 0..59
122 MINUTES
=`awk 'BEGIN {srand(); printf "%d", 60*rand()}'`
125 HOUR
=`awk 'BEGIN {srand(); printf "%d", 23*rand()}'`
127 #random day of week 0..6
128 DAY
=`awk 'BEGIN {srand(); printf "%d", 6*rand()}'`
130 #update anon one time per week
131 cru a anonupdate
"$MINUTES $HOUR * * $DAY /usr/sbin/tomatoanon"
135 else #if anon is not enabled or was disabled right now
137 ISCRU
=`cru l | grep anonupdate | wc -l`
138 if [ "$ISCRU" == "0" ]; then
142 ISCRU
=`cru l | grep checkver | wc -l`
143 if [ "$ISCRU" == "0" ]; then
149 else #if answer is not enabled or was disabled right now
151 ISCRU
=`cru l | grep anonupdate | wc -l`
152 if [ "$ISCRU" == "0" ]; then
156 ISCRU
=`cru l | grep checkver | wc -l`
157 if [ "$ISCRU" == "0" ]; then