Stealth Mode script
[tomato.git] / release / src / router / others / tomatoanon
blob3a6e8ac46b08d706a3e80c9b9ba0dad7b3278458
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 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"
42 nvram commit
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 }'`
52 else #if K26USB
53 VER=`nvram get os_version | awk '{ print $2" "$3" "$4 }' | cut -d "-" -f2`
54 BUILDTYPE=`nvram get os_version | awk '{ print $5 }'`
56 else #K2.4
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 }'`
61 else # if K24USB
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 }'`
71 rm /tmp/country
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`
77 rm /tmp/AnonLink
79 #We have all we need well we can send datas to Anon database
80 wget -O /dev/null $ANONSEND
82 #Thanks
84 INTERVAL=`nvram get tomatoanon_cru`
86 #random minutes 0..59
87 MINUTES=`awk 'BEGIN {srand(); printf "%d", 60*rand()}'`
89 cru d tomatoanon
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
96 cru d tomatoanon
99 fi #end ANON_ENABLE
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
105 cru d tomatoanon
108 fi #end ANON_ANSWER