Author: viol Date: Thu Aug 11 17:34:22 2011 New Revision: 2719 Log: add option to request selected infos from APs Modified: 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_info ============================================================================== --- trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info Thu Aug 11 14:28:58 2011 (r2718) +++ trunk/openwrt/router-configurations/pisa-testbed/usr/local/malocation/service/request_ap_info Thu Aug 11 17:34:22 2011 (r2719) @@ -2,70 +2,85 @@ . ./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' ';') - - -if [ -e /usr/sbin/hipd ]; then - HIPD_VERSION=$(hipd -V | head -n 1 | tr '\n' ';') - HIPD=$(cat $PS | grep -q hipd) -fi -if [ -e /usr/sbin/hipfw ]; then - HIPFW_VERSION=$(hipfw -V | head -n 1 | tr '\n' ';') -fi -if [ -e /usr/sbin/pisacd ]; then - PISACD_VERSION=$(pisacd -V 2>&1 | head -n 1 | tr '\n' ';') -fi -if [ -e /usr/sbin/pisasd ]; then - PISASD_VERSION=$(pisasd -V 2>&1 | head -n 1 | tr '\n' ';') -fi -if [ -e /usr/sbin/hipconf ]; then - HIPCONF_HA=$(hipconf get ha all 2>&1 | tail -n +5 | tr '\n' ';') - HIPCONF_HI=$(hipconf get hi default 2>&1 | tail -n +5 | tr '\n' ';') +set_vars () { + 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' ';') + + if [ -e /usr/sbin/hipd ]; then + HIPD_VERSION=$(hipd -V | head -n 1 | tr '\n' ';') + fi + + if [ -e /usr/sbin/hipfw ]; then + HIPFW_VERSION=$(hipfw -V | head -n 1 | tr '\n' ';') + fi + + if [ -e /usr/sbin/pisacd ]; then + PISACD_VERSION=$(pisacd -V 2>&1 | head -n 1 | tr '\n' ';') + fi + + if [ -e /usr/sbin/pisasd ]; then + PISASD_VERSION=$(pisasd -V 2>&1 | head -n 1 | tr '\n' ';') + fi + if [ -e /usr/sbin/hipconf ]; then + HIPCONF_HA=$(hipconf get ha all 2>&1 | tail -n +5 | tr '\n' ';\n') + HIPCONF_HI=$(hipconf get hi default 2>&1 | tail -n +5 | tr '\n' ';') + fi + + PROCESSES="hipd hipfw pisacd pisasd" + PS_LIST=$(ps) + PS="" + for p in $PROCESSES; do + if echo "$PS_LIST" | grep -q "$p"; then + PS="$p;$PS" + fi + done +} + +parse_query info +if [ "$info" ]; then + case $info in + CLIENT_IP | client_ip) info_json='{"client_ip":"'$REMOTE_ADDR'"}';; + UPTIME | uptime) info_json='{"uptime":"'$(uptime)'"}';; + *) info_json='{}';; + esac +else + set_vars + info_json='{ + "hostname":"'$HOSTNAME'",\n + "client_ip":"'$REMOTE_ADDR'",\n + "os_release":"'$OS_RELEASE'",\n + "os_version":"'$OS_VERSION'",\n + "uptime":"'$UPTIME'",\n + "eth0":"'$IFCONFIG_eth0'",\n + "eth1":"'$IFCONFIG_eth1'",\n + "wlan0":"'$IFCONFIG_wlan0'",\n + "br-lan":"'$IFCONFIG_brlan'",\n + "route":"'$ROUTE'",\n + "iwconfig":"'$IWCONFIG'",\n + "assoclist":"'$ASSOCLIST'",\n + "ps":"'$PS'",\n + "hipd_version":"'$HIPD_VERSION'",\n + "hipfw_version":"'$HIPFW_VERSION'",\n + "pisacd_version":"'$PISACD_VERSION'",\n + "pisasd_version":"'$PISASD_VERSION'",\n + "hipconf_hi":"'$HIPCONF_HI'",\n + "hipconf_ha":"'$HIPCONF_HA'"}' fi -PROCESSES="hipd hipfw pisacd pisasd" -PS_LIST=$(ps) -PS="" -for p in $PROCESSES; do - if echo "$PS_LIST" | grep -q "$p"; then - PS="$p;$PS" - fi -done - -info_json='{ - "hostname":"'$HOSTNAME'",\n - "client_ip":"'$REMOTE_ADDR'",\n - "os_release":"'$OS_RELEASE'",\n - "os_version":"'$OS_VERSION'",\n - "uptime":"'$UPTIME'",\n - "eth0":"'$IFCONFIG_eth0'",\n - "eth1":"'$IFCONFIG_eth1'",\n - "wlan0":"'$IFCONFIG_wlan0'",\n - "br-lan":"'$IFCONFIG_brlan'",\n - "route":"'$ROUTE'",\n - "iwconfig":"'$IWCONFIG'",\n - "assoclist":"'$ASSOCLIST'",\n - "ps":"'$PS'",\n - "hipd_version":"'$HIPD_VERSION'",\n - "hipfw_version":"'$HIPFW_VERSION'",\n - "pisacd_version":"'$PISACD_VERSION'",\n - "pisasd_version":"'$PISASD_VERSION'",\n - "hipconf_hi":"'$HIPCONF_HI'",\n - "hipconf_ha":"'$HIPCONF_HA'"}' - parse_query callback if [ "$callback" ]; then - echo -e ${callback}'('${info_json}');' + echo -e ${callback}'('$info_json');' else - echo -e ${info_json} + echo -e $info_json fi + + -- This is the pisa developer mailing list. Please also subscribe to the main pisa list at: //www.freelists.org/list/pisa