These are some scripts I've been sitting on since rc4 I thought I should share.
Just a simple script to do a wireless survey. Uses wl if available.
/www/cgi-bin/webif/wireless-survey.sh
#!/usr/bin/webif-page
<?
. /usr/lib/webif/webif.sh
header "Status" "Survey" "Wireless survey"
?>
<pre><?
use_wl() {
wl scan
sleep 3
wl scanresults
}
use_iwlist() {
iwlist $(nvram get wl0_ifname) scanning | grep -v Bit\ Rate
}
exists $(which wl) && use_wl || use_iwlist
?></pre>
<? footer ?>
<!--
##WEBIF:name:Status:4:Survey
-->
Even simpler scripts for lan and wan status, essentially the same as the current wireless status:
/www/cgi-bin/webif/lan-status.sh
#!/usr/bin/webif-page
<?
. /usr/lib/webif/webif.sh
header "Status" "WAN" "WAN status"
?>
<pre><? ifconfig 2>&1 | grep -A 6 "`nvram get wan_ifname`" ?></pre>
<? footer ?>
<!--
##WEBIF:name:Status:4:WAN
-->
/www/cgi-bin/webif/wan-status.sh
#!/usr/bin/webif-page
<?
. /usr/lib/webif/webif.sh
header "Status" "LAN" "LAN status"
?>
<pre><? ifconfig 2>&1 | grep -A 6 "`nvram get lan_ifname`" ?></pre>
<? footer ?>
<!--
##WEBIF:name:Status:3:LAN
-->
slightly modified ipkg.sh to move the add/remove buttons closer to the actual packages. Note the position of $1 and $3 in the origional lines compared to the updated lines. I thought it was hard to tell which link went with which package...
/www/cgi-bin/webif/ipkg.sh
Replace line 24 with:
print "<tr><td style=\"width: 10%\"><a href=\"ipkg.sh?action=remove&pkg=" link "\">Remove</td><td>" $1 "</td></tr>"
Replace line 42 with:
print "<tr><td style=\"Width: 10%\"><a href=\"ipkg.sh?action=install&pkg=" link "\">Install</td><td>" $3 "</td></tr>"
For the reboot script to work, a new category has to be made:
/www/cgi-bin/webif/.categories
##WEBIF:category:Info
##WEBIF:category:Status
##WEBIF:category:System
##WEBIF:category:Network
##WEBIF:category:Reboot
Then create the reboot script:
/www/cgi-bin/webif/reboot.sh
#!/usr/bin/webif-page
<?
. /usr/lib/webif/webif.sh
header "Reboot" "Rebooting" "Rebooting the Router"
timeout=60
?>
<meta http-equiv="refresh" content="<? echo $timeout ?>;url=http://<? nvram get lan_ipaddr ?>">
Will return in <? echo $timeout ?> seconds.
<? reboot ?>
<? footer ?>
<!--
##WEBIF:name:Reboot:1:Rebooting
-->
EDIT: Found a typo
EDIT2: Some people had problems with accents, changed to $()
(Last edited by bobpaul on 1 Aug 2006, 05:18)