#!/usr/bin/haserl <% echo -en "content-type: text/html\r\n\r\n" # RF2616 Compliance %> <%# --- Process the form submission --- %> <% if [ "$FORM_BUTTON" == "Save" ] || [ "$FORM_BUTTON" == "Save&Apply" ]; then uci set wireless.ap_0.ssid="$FORM_SSID" uci set wireless.ap_0.encryption="$FORM_ENCRYPTION" uci set wireless.ap_0.key="$FORM_KEY" uci set wireless.radio0.txpower="$FORM_TXPOWER" uci set wireless.radio0.wifi_mode="$FORM_WIFI_MODE" uci set wireless.radio0.wan_lan="$FORM_WAN_LAN" uci set wireless.sta_0.ssid="$FORM_HOST_SSID" uci set wireless.sta_0.encryption="$FORM_HOST_ENCRYPTION" uci set wireless.sta_0.key="$FORM_HOST_KEY" # Set channel only if wwan sta mode not in use, and channel is not null sta_chk=$(uci get wireless.sta_0.disabled) if [ "$sta_chk" == "1" ] && [ ! -z "$FORM_CHANNEL" ]; then uci set wireless.radio0.channel="$FORM_CHANNEL" fi uci commit wireless fi if [ "$FORM_BUTTON" == "Save&Apply" ]; then # Set up WiFi AP if [ "$FORM_AP_ENABLE" == "checked" ]; then uci set wireless.ap_0.disabled="0" else uci set wireless.ap_0.disabled="1" fi # Set up WiFi WAN Client if [ "$FORM_WIFI_WAN_ENABLE" == "checked" ]; then uci set wireless.sta_0.disabled="0" else uci set wireless.sta_0.disabled="1" fi uci commit wireless [ -f /var/log/wifi_handle.txt ] && rm /var/log/wifi_handle.txt; # Run in background (sleep 1; /etc/init.d/network restart) & (sleep 30; /etc/init.d/fallbackip start) & #/etc/init.d/DR_wifi_wan start & # Check that WiFi WAN is operating correctly, else disable after 30 seconds. fi %> <%# --- Get the variables for the HTML page --- %> <% ssid="$(uci -q get wireless.ap_0.ssid)" encryption="$(uci -q get wireless.ap_0.encryption)" key="$(uci -q get wireless.ap_0.key)" txpower="$(uci -q get wireless.radio0.txpower)" channel=$(uci -q get wireless.radio0.channel) host_ssid="$(uci -q get wireless.sta_0.ssid)" host_encryption="$(uci -q get wireless.sta_0.encryption)" host_key="$(uci -q get wireless.sta_0.key)" ap_disabled="$(uci -q get wireless.ap_0.disabled)" if [ "$ap_disabled" == "0" ]; then ap_enable="checked" #channel=$(iw dev |grep -A 1 AP | grep channel | cut -d " " -f2) else ap_enable="0" #channel=$(uci -q get wireless.radio0.channel) fi wifi_wan_enable="0" sta_disabled="$(uci -q get wireless.sta_0.disabled)" if [ "$sta_disabled" == "0" ]; then wifi_wan_enable="checked" #wan_str="    Note: Ethernet WAN port will be disabled " channel=$(iw dev |grep -A 1 managed | grep channel | cut -d " " -f2) fi %> <%# --- Present the HTML page --- %> <%inc /www/cgi-bin/inc/head.inc %> <%inc /www/cgi-bin/inc/menu.inc %>

WiFi

<% if [ -n /var/log/wifi_handle.txt ]; then %> <% fi %>

Radio Settings

WiFi Access Point Settings

Enable WiFi Access Point   >
Show

WiFi WAN Client Settings

Enable WiFi WAN Client   >
Show
<% cat /var/log/wifi_handle.txt %>
<% # Check wifi operation wifi_op=$(iw dev | grep -c channel) %> <% if [ "$wifi_wan_enable" == "checked" ] && [ "$wifi_op" == "0" ]; then %> <% elif [ "$wifi_wan_enable" == "checked" ] && [ $wifi_op -gt "0" ]; then %> <% fi %> <% # Scan for SSID information and store. iwinfo radio0 scan > /tmp/scan.txt %> <% # Check for wwan host host_chk=$(cat /tmp/scan.txt | grep -c "\"$host_ssid\"") if [ $wifi_wan_enable == "checked" ] && [ $host_chk == "0" ]; then %> <% fi %> <% # Build scan SSID list ssid_str=""$ssid_str str=$(cat /tmp/scan.txt | grep "Address" | cut -d : -f 2-7) for addr in $str do if [ $(cat /tmp/scan.txt |grep -w -A 4 "$addr" |grep -c "mixed WPA/WPA2 PSK") == "1" ]; then encr="psk-mixed" encr_str="WPA/WPA2" elif [ $(cat /tmp/scan.txt |grep -w -A 4 "$addr" |grep -c "WPA2 PSK") == "1" ]; then encr="psk2" encr_str="WPA2" elif [ $(cat /tmp/scan.txt |grep -w -A 4 "$addr" |grep -c "WPA PSK") == "1" ]; then encr="psk" encr_str="WPA" elif [ $(cat /tmp/scan.txt |grep -w -A 4 "$addr" |grep -c "WEP") == "1" ]; then encr="wep" encr_str="WEP" elif [ $(cat /tmp/scan.txt |grep -w -A 4 "$addr" |grep -c "none") == "1" ]; then encr="none" encr_str="None" else encr="psk-mixed" encr_str="WPA/WPA2" fi sig=$(cat /tmp/scan.txt | grep -w -A 3 "$addr" | grep "Signal" | cut -d : -f 2 | cut -d " " -f2,3) chan=$(cat /tmp/scan.txt| grep -w -A 2 "$addr" | grep "Channel" | cut -d : -f3) ssid=$(cat /tmp/scan.txt| grep -w -A 1 "$addr" | grep "ESSID" | cut -d : -f2 | sed 's/ //'| sed 's/"//g') ssid_str=""$ssid_str done %>