#!/usr/bin/webif-page >/tmp/.startup_log } empty $FORM_unfallback || { rm -f /etc/.fallback-mode echo "`uptime | awk -F" " '{print $1}'`: fallback unloaded by user, reboot please" >>/tmp/.startup_log } empty $FORM_delete_log || { echo "`uptime | awk -F" " '{print $1}'`: startup log deleted by user" >/tmp/.startup_log } zerofill() { [ ${#1} = 1 ] && echo 0$1 || echo $1 } table_active_connections() { # $1 = interface online_file=/tmp/online tmp=/tmp/wlan_list_$$.tmp; wlanconfig $1 list | grep -v UAPSD 2> /dev/null >$tmp wlanuser=/tmp/wlanuser_$$.tmp touch $wlanuser touch $online_file touch /etc/blockmac touch /etc/blockuser lines=`wc -l $tmp`;lines=${lines% *} lines_on=`wc -l $online_file`;lines_on=${lines_on% *} [ $1 = ath1 ] && lines2=$lines || lines2=$lines_on if [ $lines != 0 -o $lines2 != 0 ];then [ "$1" = "ath0" ] && { infohead="add_normal_cell|@TR<>" file=$online_file } || file=$tmp display_form <@TR<> add_normal_cell|@TR<> add_normal_cell|@TR<> add_normal_cell|@TR<> $infohead add_normal_cell|@TR<> end_row EOF online() { now=`date +%s`; now_min=$((now/60));now_sec=$((now-now_min * 60)); cat $1 | grep -v ADDR|while read i do pic=/images/a.gif blocked=0 mac=`echo $i | awk '{print $1}'|tr a-z A-Z` mac_nr=`echo $mac | awk -F: '{print $1"-"$2"-"$3}'` mac_link=`echo ""$mac""` grep -i $mac $tmp >>$wlanuser && lan=0 || lan=1 [ $lan = 0 ] && { wlanconn=`grep -i $mac $tmp` speed=`echo $wlanconn| awk '{print $4}'` sigspeed=${speed%M} [ -z $sigspeed ] && sigspeed=1 signal=$((100*$sigspeed/54*scale/100)) [ $signal -gt $scale ] && signal=$scale gray=$((scale-signal)) } || { grep -q -i $mac /etc/blockmac && blocked=1 gray=0 signal=$((100*54/54*scale/100)) } touch /tmp/dhcp.leases ip=`cat /proc/net/arp | grep $2 | grep -i $mac | awk '{print $1}'` if [ "$ip" = "" ]; then ip=`grep -i "$mac" /tmp/dhcp.leases | awk -F" " '{print $3}'` && [ "$ip" != "" ] && ip="$ip (dhcp.leases)" fi if [ "$ip" = "" ]; then touch /etc/ethers ip=`grep -i "$mac" /etc/ethers | awk -F" " '{print $2}'` && [ "$ip" != "" ] && ip="$ip (ethers)" fi if [ "$ip" = "" ]; then ip="*@TR<>*" fi name=`grep -i $mac /tmp/dhcp.leases | awk '{print $4}'` grep -q $mac $file 2>/dev/null && online=1 || online=0 case "$online" in 1) user=`grep $mac $file | cut -d" " -f3` grep -q -i $user /etc/blockuser && blocked=1 timeout=`grep $mac $file | cut -d" " -f4`; timeout_min=$((timeout/60)); timeout_sec=$((timeout-timeout_min * 60)); ip=`grep $mac $file | cut -d" " -f2` since=`grep $mac $file | cut -d" " -f5`; since_min=$((since/60)); since_sec=$((since-since_min * 60)); #since=$((now-since)) since_sec=$((now_sec-since_sec)) test $since_sec -lt 0 && { since_sec=$((since_sec + 60)) since_min=$((since_min - 1)) } since_min=$((now_min - since_min)) residual="@TR<>" new_timeout_min=0 new_timeout_sec=0 if [ "$timeout" != "0" ]; then new_timeout_sec=$((timeout_sec - $since_sec)) test $new_timeout_sec -lt 0 && { new_timeout_sec=$((new_timeout_sec + 60)) new_timeout_min=$((new_timeout_min - 1)) } new_timeout_min=$((timeout_min - since_min)) residual="$((new_timeout_min)):$(zerofill $new_timeout_sec)min" fi since_title=" @TR<>: $((since_min)):$(zerofill $since_sec)min" residual_tilte=" @TR<>: $residual" if [ "$timeout" = "0" ]; then img="\"$user\"Linus/Bill:
@TR<>: $user
$since_title
$residual_tilte
"; else img="\"$user\"Alien:
@TR<>: $user
$since_title
$residual_tilte
"; fi ;; 0) user="" img="\"@TR<<not>\">@TR<>:
@TR<>
"; ;; esac; [ $blocked = 1 ] && { speed="Blocked" pic=/images/c.gif } || [ $lan = 1 ] && { pic=/images/orange.gif speed="LAN or disconnected" } [ "$2" = "ath0" ] && { infocell="add_normal_cell|$img"; name="$user"; } [ $lan = 0 -a $blocked = 0 ] && blockmaccell="add_normal_cell|@TR<>" display_form <$speed $infocell $blockmaccell end_row EOF done } online $file $1 touch /tmp/newlist cat $tmp|grep -v ADDR|while read s;do tmpmac=`echo $s|cut -d" " -f1` grep -q -i $tmpmac $online_file || echo $s >>/tmp/newlist done [ $1 = ath0 ] && online /tmp/newlist $1 rm /tmp/newlist display_form <> add_normal_cell|(MAC blocking) end_row end_table EOF fi rm $wlanuser rm $tmp } config_load fon config_get mode wan mode config_get dhcpname wan dhcpname get_default wanmode wan mode config_get pubssid public essid config_get privssid private essid config_get encryption private encryption config_get priv_hidden private hidden config_get bridge wan bridge . /tmp/network-config >/dev/null 2>/dev/null bg="" case "$FORM_wanmode" in static) wanmode="Static" ;; dhcp) wanmode="DHCP" ;; pppoe) wanmode="PPPoE" ;; pptp) wanmode="PPTP" ;; wlan) wanmode="WLAN" bg="`iwconfig ath2 2>/dev/null | grep 802.11 | awk -F" " '{print $3}'`" ;; *) wanmode="Unknown" ;; esac if [ "$wanmode"="WLAN" ]; then wan_ap="$(iwconfig ath2 2>/dev/null | grep 'Access Point' | awk -F'[ ]+' '{print $7}')" /bin/generateSiteSurveyHtmlCode.sh $wan_ap & else /bin/generateSiteSurveyHtmlCode.sh & fi if [ `echo "$(iwpriv ath1 get_hide_ssid | awk -F":" '{print $2}')"` = 1 ]; then priv_hidden="@TR<>" else priv_hidden="" fi wan_gw="$(route -n | grep '^0.0.0.0' | awk '{print $2}')" touch /etc/resolv.conf for ns in $(grep nameserver /etc/resolv.conf | awk '{print $2}'); do wan_ns="${wan_ns:+$wan_ns, }$ns" done /usr/sbin/brctl show | grep -q "br1" if [ "$?" = "0" ]; then lanif=br1 bridged="@TR<>" else lanif=ath1 bridged="" fi /usr/sbin/brctl show | grep -q "br0" if [ "$?" = "0" ]; then FONbridged="@TR<>" else FONbridged="" fi priv_ip="$(ifconfig $lanif 2>/dev/null | grep inet | awk -F'[: ]+' '{print $4}')" txp="$(iwlist ath1 tx | grep Tx-Power | awk -F":" '{print $2}')" [ -z "$txp" ] && txp="$(iwlist ath1 tx | grep Tx-Power | awk -F"=" '{print $2}')" freq="$(iwlist ath1 channel | grep Current | awk -F":" '{print $2}')" >&- 2>&- version="$(cat /etc/fon_version) r$(cat /etc/fon_revision)" addonversion="$(cat /etc/addon_version)" [ -f /etc/addons_hotfix_version ] && addonshotfixversion="$(cat /etc/addons_hotfix_version)" memoryinfo="`free | grep Total | cut -d":" -f2`" memory_total="`echo $memoryinfo | awk '{print $1}'`" memory_used="`echo $memoryinfo | awk '{print $2}'`" memory_free="`echo $memoryinfo | awk '{print $3}'`" datum=`date` header "Router Status - Freewlan Addons $addonversion" cat < EOF display_form <>|tableTextButton EOF if [ ! -f /etc/.fallback-mode ]; then if [ ! -f /tmp/.startup_complete ]; then display_form <>|tableTextButton end_row EOF fi else display_form <>|tableTextButton end_row add_row add_label_cell add_label_cell add_label_cell add_label_cell|!!!fallback mode!!!
No changes take effect till reboot.
end_row EOF fi if [ "$FORM_passphrase" != "" ]; then display_form <
EXECUTING CONFIGURATION" echo "

@TR<>..." else display_form <> end_row end_table EOF table_active_connections ath1 equal "x`/etc/init.d/N50chillispot alive`" "xchillispot is alive" && { display_form <> end_row end_table EOF table_active_connections ath0 } display_form <> end_row add_row add_label_cell|@TR<> add_label_cell|$version end_row add_row add_label_cell|@TR<> add_label_cell|$addonversion end_row EOF if ! empty $addonshotfixversion; then display_form <> add_label_cell|svn$addonshotfixversion end_row EOF fi display_form <> add_label_cell|$datum EOF if [ "`echo $datum | awk '{print $2$3}'`" = "Sep19" ]; then display_form <Happy birthday, Rosalie! EOF fi display_form < EOF display_form <> end_row add_row add_label_cell|@TR<> add_label_cell|$wanmode $bg end_row EOF case $mode in "wlan") ath2_pwr="$(iwconfig ath2 2>/dev/null | grep Bit | awk 'FS=":" {print $2}' | awk '{print $1}')" quality=$(iwconfig ath2 2>/dev/null | grep Quality | awk -F"=" '{print $2}' | awk -F" " '{print $1}' | awk -F"/" '{print $1}') ifconfig ath2 >/dev/null 2>&1 || { ath2_pwr=1; quality=0; } speed=$((100*$ath2_pwr/54)) [ $speed -gt $scale ] && speed=$scale gray=$((scale-speed)) pub_mac="$(ifconfig ath0 2>/dev/null | grep HWaddr | awk -F'[ ]+' '{print $5}')" wan_mac="$(ifconfig ath2 2>/dev/null | grep HWaddr | awk -F'[ ]+' '{print $5}')" rssid="$(iwconfig ath2 2>/dev/null | grep ESSID | awk -F"\"" '{print $2}')" bridge_ip="$(ifconfig ath2 2>/dev/null | grep inet | awk -F'[: ]+' '{print $4}')" display_form <> add_label_cell|$rssid end_row add_row add_label_cell|@TR<> add_label_cell|$wan_ap end_row add_row add_label_cell|@TR<>/@TR<> add_normal_cell|${speed}M${speed}M/${quality}/98${quality}/98 end_row add_row add_label_cell|@TR<> add_label_cell|$wan_mac end_row add_row add_label_cell|@TR<> add_label_cell|${bridge_ip:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|${wan_gw:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|${wan_ns:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|$dhcpname end_row EOF ;; *) pub_mac="$(ifconfig ath0 2>/dev/null | grep HWaddr | awk -F'[ ]+' '{print $5}')" priv_mac="$(ifconfig ath1 2>/dev/null | grep HWaddr | awk -F'[ ]+' '{print $5}')" wan_mac="$(ifconfig eth0 2>/dev/null | grep HWaddr | awk -F'[ ]+' '{print $5}')" wan_ip="$(ifconfig "${wan_ifname:-eth0}" 2>/dev/null | grep inet | awk -F'[: ]+' '{print $4}')" display_form <> add_label_cell|$wan_mac end_row add_row add_label_cell|@TR<> add_label_cell|${wan_ip:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|${wan_gw:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|${wan_ns:-N/A} end_row EOF ;; esac display_form < EOF display_form <> end_row EOF equal "x`/etc/init.d/N50chillispot alive`" "xchillispot is alive" && { display_form <> add_label_cell|FON_$pubssid $FONbridged end_row add_row add_label_cell|@TR<> add_label_cell|$pub_mac end_row EOF } || { display_form <> add_label_cell|@TR<> end_row add_row add_label_cell| end_row EOF } display_form <> add_label_cell|$privssid $priv_hidden end_row add_row add_label_cell|@TR<> add_label_cell|${encryption:-none} end_row add_row add_label_cell|@TR<> add_label_cell|${priv_ip:-N/A} $bridged end_row add_row add_label_cell|@TR<> add_label_cell|${freq:-N/A} end_row add_row add_label_cell|@TR<> add_label_cell|${txp:-N/A} end_row end_table EOF cat < EOF display_form <> add_label_cell|@TR<> end_row end_table EOF cat < EOF display_form <
Sig./dBm
-10 -20 -30 -40 -50 -60 -70 -80 -90 -100

EOF S_FILE=/tmp/.graphsurvey while [ -f /tmp/survey.lock ]; do sleep 1 done; # wait for survey to be generated completely echo `cat $S_FILE` rm -f $S_FILE cat <

@TR<>.

EOF display_form <> add_label_cell add_label_cell add_button_cell|delete_log|@TR<>|tableTextButton end_row end_table start_table|0|10|5 add_row EOF echo "" display_form <>|tableTextButton end_row end_table EOF fi if [ "$FORM_passphrase" != "" ]; then if [ "`ifconfig | grep -q ath2; echo "$?"`" -eq "1" ]; then ifconfig ath2 up fi . /etc/functions.sh config_load fon get_default oldenc wan enc reboot_mandatory=0; # determine encryption type encswitch="$(iwlist ath2 scanning 2>/dev/null | grep -iA5 "$FORM_bssid" | grep "Encryption key" | awk -F":" '{print $2}')" case $encswitch in on) enctype=$(iwlist ath2 scanning 2>/dev/null | grep -iA13 "$FORM_bssid" | grep "Group Cipher" | awk '{print $4}') case $enctype in TKIP|CCMP) save_setting fon wan enc "WPA" [ "$FORM_oldenc" != "WPA" ] && reboot_mandatory=1; save_setting fon wan oldenc "WPA" ;; *) # WEP save_setting fon wan enc "WEP" [ "$FORM_oldenc" != "WEP" -a "$FORM_oldenc" != "off" ] && reboot_mandatory=1; save_setting fon wan oldenc "WEP" ;; esac save_setting fon wan key "$FORM_passphrase" ;; off) save_setting fon wan enc "off" [ "$FORM_oldenc" != "WEP" -a "$FORM_oldenc" != "off" ] && reboot_mandatory=1; save_setting fon wan oldenc "off" ;; esac echo "

connecting to AP: $FORM_bssid
encryption is switched $encswitch
using DHCP Server
" save_setting fon wan mode "wlan" save_setting fon wan dhcp "1" save_setting fon wan bssid "$FORM_bssid" commit_settings if [ "$reboot_mandatory" -eq "1" ]; then echo "

REBOOT mandatory" footer display_form </dev/null fi else footer fi; ?>