#!/bin/sh # export DATE="12.4.2006";SCRIPT=${0#/rom} # export TITLE="Status: OLSR" . ./cgi-bin-pre.sh . /var/run/freifunk_register.conf WLDEV=$(iwconfig 2>/dev/null | sed -n '/^wlan[0-9]/s/ .*$//p') if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ "$QUERY_STRING" != "${QUERY_STRING#*post_olsr=}" ]; then if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat<Status: OLSR
# s/./&/ tn c\ <\/TABLE> p } ' cat<
EOF cat<    EOF if [ "$FREIFUNK_GUI_SHOW_ROUTING" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_WLANSCAN" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat< EOF fi cat<
 
EOF wget -q -O - http://127.0.0.1:2006/ | sed -ne' /^Table:/,/^$/{ s#^Table: \(.*\)#

\1

<\TABLE BORDER="1" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"># :n p n s#[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+#&#g s/ / - /g s/ $// s# #
#g s#.\+#
&
EOF fi elif [ "$QUERY_STRING" != "${QUERY_STRING#*post_route=}" ]; then if [ "$FREIFUNK_GUI_SHOW_ROUTING" = "yes" ]; then cat<Status: Routen
\ #\ #\ # #s#\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\([^/]\)#\1\2#g #' #echo '<''/TABLE>' #} #else #{ netstat -r | awk ' function td(s) { print "" #} function ip(s) { if(!/\//&&s!="default"&&s!="Kernel"&&s!="Destination"&&s>"104.0.0.0"&&s<"105.") { td(sprintf("%s", s, s)) } else { td(s) } } BEGIN { print "<""TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">" } { print "" ip($1) s="" for(i=2;i<=NF;i++) s=s" "$i td(s) print "" } END { print "<""/TABLE>" }' } cat<
EOF cat<    EOF if [ "$FREIFUNK_GUI_SHOW_ROUTING" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_WLANSCAN" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat< EOF fi cat<
 
EOF # check for FLI4L version #if [ -f /sbin/ip ] # then #{ #echo '<''TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">' #ip route show | sed -e' #s#^\([^ ]\+\)\(.*\)#
\1\2
"s"
EOF fi elif [ "$QUERY_STRING" != "${QUERY_STRING#*post_scan=}" ]; then if [ "$FREIFUNK_GUI_SHOW_WLANSCAN" = "yes" ]; then cat<Status: WLAN Scan
EOF for DEV in $WLDEV do cat< ' count=0 iwlist $DEV scan | sed \ -e 's/ dBm//g' \ -e 's/)//g' \ -e 's/(//g' \ -e 's/.*Scan completed.*//' \ -e 's/.*Address: /BSSID=/' \ -e 's/.*ESSID:/SSID=/' \ -e 's/.*Mode:/MODE=/' \ -e 's/.*Channel /CHANNEL=/' \ -e 's/.*Signal level=-/RSSI=/' \ -e 's/Noise level=-/; NOISE=/' \ -e 's/.*Encryption key:/CLOSED=/' \ -e 's/.*Mb\/s; /RATE=/' -e 's/Mb\/s//' \ -e 's/.*Extra:.*/END=1/' \ -e 's/.*IE:.*//' \ -e 's/.*Group Cipher.*//' \ -e 's/.*Authentication Suites.*//' \ -e 's/.*Pairwise Ciphers.*//' \ -e 's/.*Preauthentication Supported.*//' \ -e '/^ *$/d' \ | while read line; do eval $line 2>/dev/null if [ "$END" == "1" ] ; then END="" gif=$(echo $NOISE - $RSSI | bc) gif=$(echo $gif / 5 | bc) test $gif -gt 5 && gif=5 test $gif -lt 0 && gif=0 if [ $CLOSED == "on" ] ; then OPEN="no" fi if [ $CLOSED == "off" ] ; then OPEN="yes" fi ADHOC="no" if [ $MODE == "Ad-Hoc" ] ; then ADHOC="yes" fi cat< EOF fi done 2>/dev/null echo '
EOF cat<    EOF if [ "$FREIFUNK_GUI_SHOW_ROUTING" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_WLANSCAN" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat< EOF fi cat<
 
$DEV
SSID Kanal Ad-Hoc Open Signal Max. BSSID
EOF #/usr/sbin/wl -i $WLDEV scan sleep 2 echo '
$SSID$CHANNEL ad hoc $OPEN P=$gif $RATE$BSSID
 ' done cat<
EOF fi else cat<Status: Übersicht
EOF idx=1 while [ "$idx" -le "$FREIFUNK_INTERFACE_N" ] do # evaluate interface eval temp='$FREIFUNK_INTERFACE_'$idx'_DEV' eval temp2='$FREIFUNK_INTERFACE_'$idx'_MASK' eval temp3='$FREIFUNK_INTERFACE_'$idx'_MAC' eval temp4='$FREIFUNK_INTERFACE_'$idx'_IP' # WLMASK=$(ip -f inet addr show dev $DEV label $DEV |sed -ne'2{s# \+inet \([0-9\.\/]\+\).*#\1#;p}') if [ "$temp3" = '' ] then { $temp3= "IP_NET_x_MAC has to be set for wireless interface in base.txt" } fi cat< EOF # index um eins erhoehen idx=`/usr/bin/expr $idx + 1` done MYTIME=`/bin/cat /proc/uptime | /usr/bin/cut -d' ' -f1 | /usr/bin/cut -d'.' -f1` SEC=`/usr/bin/expr $MYTIME % 60` MYTIME=`/usr/bin/expr $MYTIME / 60` MIN=`/usr/bin/expr $MYTIME % 60` MYTIME=`/usr/bin/expr $MYTIME / 60` HRS=`/usr/bin/expr $MYTIME % 24` DAYS=`/usr/bin/expr $MYTIME / 24` LOADMIN=`/bin/cat /proc/loadavg | /usr/bin/cut -d' ' -f3` LOAD=`/bin/cat /proc/loadavg | /usr/bin/cut -d' ' -f2` LOADMAX=`/bin/cat /proc/loadavg | /usr/bin/cut -d' ' -f1` cat< EOF if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat< # s/./&/ tn c\ <\/TABLE> p } ' fi cat< EOF if [ "$FREIFUNK_GUI_SHOW_BOOTLOG" = "yes" ]; then cat< EOF fi if [ "$FREIFUNK_GUI_SHOW_IPNAT" = "yes" ]; then cat< EOF fi if [ "$FREIFUNK_GUI_SHOW_INTERFACES" = "yes" ]; then cat< EOF fi if [ "$FREIFUNK_GUI_SHOW_CONNECTIONS" = "yes" ]; then cat< EOF fi cat<
EOF cat<    EOF if [ "$FREIFUNK_GUI_SHOW_ROUTING" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_WLANSCAN" = "yes" ]; then cat<  EOF fi if [ "$FREIFUNK_GUI_SHOW_OLSRINFO" = "yes" ]; then cat< EOF fi cat<
 
$temp
IP Adresse: IP: $temp4, Maske:  $temp2 , MAC: $temp3
WLAN-Status: $(iwconfig $temp 2>&1)
Gerätelaufzeit: $HRS:$MIN:$SEC up $DAYS days, $(date "+%H:%M"), load average: $LOADMIN, $LOAD, $LOADMAX
Geräteinfo: Boardtype: PC compatible
Nachbarn: EOF wget -q -O - http://127.0.0.1:2006/neighbours | sed -ne' /^Table: Links/{ s/.*/<\TABLE FRAME="VOID" BORDER="1" CELLSPACING="0" CELLPADDING="1" WIDTH="100%">/ :n p n s/^[^ ]* // s/^remote // s#\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\([^/]\)#\1\2#g s/ $// s# ##g s#.\+#
&
Boot-Log: Ein-/ Ausblenden
EOF echo -n '' if [ -f /var/log/syslog ] >/dev/null; then cat<
System-Log: Ein-/ Ausblenden
EOF echo -n '' fi cat<
IP-NAT: Ein-/ Ausblenden
EOF echo -n '' cat<
Schnittstellen-Konfiguration: Ein-/ Ausblenden
EOF echo -n '' cat<
Aktive Verbindungen: Ein-/ Ausblenden
EOF echo -n '
EOF fi . ./cgi-bin-post.sh