#!/bin/sh getip() { if [ "$R" = "0" ]; then echo "Current external IP address is:"; fi cat /etc/live.cfg | grep IPADDR | sed 's/.*=//' } getnetinfo() { X=`cat /etc/live.cfg | grep GATEWAY | sed 's/.*=//'` echo "Current gateway is: $X" X=`cat /etc/live.cfg | grep DNSADDR | sed 's/DNSADDR=/Primary DNS server: /; s/DNSADDR1=/Secondary DNS server: /'` echo "$X" } getuptime() { if [ "$R" = "0" ]; then U=`uptime | sed 's/, /, /; /.*up/!d; s///; /,..[0-9].user.*/!d; s///; s/:/ hours, /; '` echo "Router has been up for: $U minutes"; else cat /proc/uptime | sed 's/[.].*//'; fi } getversion() { if [ "$R" = "0" ]; then echo "Router is running on:"; fi cat /proc/version | sed 's/(.*//' } getprobesummary() { # get /bin/probes from our "probe detection" article if [ -f /bin/probes ]; then /bin/probes fi } R=`echo $QUERY_STRING | sed '/.*raw=/!d; s///'` Q=`echo $QUERY_STRING | sed '/^req=*/!d; s///; s/\&.*//'` if [ "$R" != "1" ]; then R="0"; fi cat <<-! Content-type: text/plain ! case "$Q" in "ipaddr") getip;; "uptime") getuptime;; "netinfo") getnetinfo;; "version") getversion;; "probes") getprobesummary;; "summary") getip getuptime getversion getnetinfo ;; *) echo "Invalid request.";; esac # End