[pisa-src] r2529 - in trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service: request_ap_coordinates request_ap_info request_parser

  • From: Nicolai Viol <Nicolai.Viol@xxxxxxxxxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 13 Apr 2011 14:27:54 +0200

Author: viol
Date: Wed Apr 13 14:27:52 2011
New Revision: 2529

Log:
changed scripts according diegos comments and added some more info capturing

Added:
   
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_parser
Modified:
   
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_coordinates
   
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info

Modified: 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_coordinates
==============================================================================
--- 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_coordinates
        Mon Apr 11 13:17:37 2011        (r2528)
+++ 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_coordinates
        Wed Apr 13 14:27:52 2011        (r2529)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-COORDs_FILE="/etc/malocation/coordinates.config"
+. ./request_parser
+
+COORDS_FILE="/etc/malocation/coordinates.config"
 ALT_COORDS_FILE="/usr/local/malocation/coordinates.config"
 
 if [ -e ${COORDS_FILE} ]; then
@@ -11,34 +13,6 @@
     coords='"longitude":0.0,"latitude":0.0,"altitude":0.0,"accuracy":0.0'
 fi
 
-parse_query() #@ USAGE: parse_query var ...
-{
-    local var val
-    local IFS='&'
-    vars="&$*&"
-    [ "$REQUEST_METHOD" = "POST" ] && read QUERY_STRING
-    set -f
-    for item in $QUERY_STRING; do
-      var=${item%%=*}
-      val=${item#*=}
-      val=${val//+/ }
-      case $vars in
-          *"&$var&"* )
-              case $val in
-                  *%[0-9a-fA-F][0-9a-fA-F]*)
-                       ## Next line requires bash 3.1 or later
-                       printf -v val "%b" "${val//\%/\\x}."
-                       ## Older bash, use: val=$( printf "%b"
-                       ## "${val//\%/\\x}." )
-                       val=${val%.}
-              esac
-              eval "$var=\$val"
-              ;;
-      esac
-    done
-    set +f
-}
-
 parse_query callback
 if [ "$callback" ]; then
     echo ${callback}'({'${coords}'});'

Modified: 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info
==============================================================================
--- 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info
       Mon Apr 11 13:17:37 2011        (r2528)
+++ 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info
       Wed Apr 13 14:27:52 2011        (r2529)
@@ -1,62 +1,35 @@
 #!/bin/sh
 
-HOSTNAME=`uname -n`
-OS_RELEASE=`uname -r`
-OS_VERSION=`uname -v`
-UPTIME=`uptime`
-IFCONFIIG_eth0=`ifconfig eth0`
-IFCONFIIG_eth1=`ifconfig eth1`
-IFCONFIIG_wlan0=`ifconfig wlan0`
-IFCONFIIG_br_lan=`ifconfig br_lan`
-ROUTE=`route`
-IWCONFIG=`iwconfig wlan0`
-ASSOCLIST=`iw dev wlan0 station dump`
-HIP_VERSION=`hipd -V`
+. ./request_parser
+
+HOSTNAME=$(uname -n)
+OS_RELEASE=$(uname -r)
+OS_VERSION=$(uname -v)
+UPTIME=$(uptime)
+IFCONFIG_eth0=$(ifconfig eth0 | tr '\n' ';')
+IFCONFIG_eth1=$(ifconfig eth1 | tr '\n' ';')
+IFCONFIG_wlan0=$(ifconfig wlan0  | tr '\n' ';')
+IFCONFIG_brlan=$(ifconfig br-lan | tr '\n' ';')
+ROUTE=$(route -n | tr '\n' ';')
+IWCONFIG=$(iwconfig wlan0 | tr '\n' ';')
+ASSOCLIST=$(iw dev wlan0 station dump | tr '\n' ';')
+HIP_VERSION=$(hipd -V | tr '\n' ';')
 
 
 info_json='{
    "hostname":"'$HOSTNAME'",
+   "client_ip":"'$REMOTE_ADDR'",
    "os_release":"'$OS_RELEASE'",
    "os_version":"'$OS_VERSION'",
    "uptime":"'$UPTIME'",
    "eth0":"'$IFCONFIG_eth0'",
    "eth1":"'$IFCONFIG_eth1'",
    "wlan0":"'$IFCONFIG_wlan0'",
-   "br_lan":"'$IFCONFIG_br_lan'",
+   "br-lan":"'$IFCONFIG_brlan'",
    "route":"'$ROUTE'",
    "iwconfig":"'$IWCONFIG'",
    "assoclist":"'$ASSOCLIST'",
-   "hip_version":"'$HIP_VERSION'",
-}'
-
-
-parse_query() #@ USAGE: parse_query var ...
-{
-    local var val
-    local IFS='&'
-    vars="&$*&"
-    [ "$REQUEST_METHOD" = "POST" ] && read QUERY_STRING
-    set -f
-    for item in $QUERY_STRING; do
-      var=${item%%=*}
-      val=${item#*=}
-      val=${val//+/ }
-      case $vars in
-          *"&$var&"* )
-              case $val in
-                  *%[0-9a-fA-F][0-9a-fA-F]*)
-                       ## Next line requires bash 3.1 or later
-                       printf -v val "%b" "${val//\%/\\x}."
-                       ## Older bash, use: val=$( printf "%b"
-                       ## "${val//\%/\\x}." )
-                       val=${val%.}
-              esac
-              eval "$var=\$val"
-              ;;
-      esac
-    done
-    set +f
-}
+   "hip_version":"'$HIP_VERSION'"}'
 
 parse_query callback
 if [ "$callback" ]; then

Added: 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_parser
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_parser
        Wed Apr 13 14:27:52 2011        (r2529)
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+parse_query() #@ USAGE: parse_query var ...
+{
+    local var val
+    local IFS='&'
+    vars="&$*&"
+    [ "$REQUEST_METHOD" = "POST" ] && read QUERY_STRING
+    set -f
+    for item in $QUERY_STRING; do
+      var=${item%%=*}
+      val=${item#*=}
+      val=${val//+/ }
+      case $vars in
+          *"&$var&"* )
+              case $val in
+                  *%[0-9a-fA-F][0-9a-fA-F]*)
+                       printf -v val "%b" "${val//\%/\\x}."
+                       val=${val%.}
+              esac
+              eval "$var=\$val"
+              ;;
+      esac
+    done
+    set +f
+}
+
-- 
This is the pisa developer mailing list. Please also subscribe to the main pisa 
list at:
//www.freelists.org/list/pisa

Other related posts:

  • » [pisa-src] r2529 - in trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service: request_ap_coordinates request_ap_info request_parser - Nicolai Viol