MyPage

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 15:11, 7 January 2010 (edit)
Gi-minni (Talk | contribs)
(Changelog)
← Previous diff
Revision as of 15:15, 7 January 2010 (edit) (undo)
Gi-minni (Talk | contribs)
(Requirements)
Next diff →
Line 57: Line 57:
'''mypage10.sh''' is named '''Ports'''.<br> '''mypage10.sh''' is named '''Ports'''.<br>
-This scripts shows periodically all the open network ports of your device. This is an autorefresh page.+This scripts shows periodically all the open and established network ports of your device. This is an autorefresh page.
'''mypage11.sh''' is named '''Logs'''.<br> '''mypage11.sh''' is named '''Logs'''.<br>

Revision as of 15:15, 7 January 2010

Contents

Introduction

The main advantage to expand the DD-WRT web interface with your own scripts is the ability to quickly see what happens with your router without opening an ssh or telnet shell and thinking around which command must be executed to see some useful results.

Many of us that use DD-WRT have small or no Linux skill, so it is great to have the most useful Linux command executed inside a web page, just click one of this tabs and be happy.

Mypage depends on the NVRAM variable mypage_scripts. Usually this variable is not set and normally you don't care about it. To enable Mypage you must set this variable to test if the Mypage tab appear right hand of the status tab.

If you cannot see the Mypage tab, upgrade your firmware to the latest build and read carefully the next sections to understand what are the prerequisites needed and how to install and configure this pages.

Prerequisite

You need at least Eko's or Brainslayer's firmware builds equal or greater than revision level svn13309. (See DD-WRT Download)

Look at the syntax of some useful Linux commands. (See Useful Scripts)

Look how to use Telnet or SSH to gain access to the command shell. (See Telnet/SSH)

Look how to setup the variable using nvram. (See Hardware)

Look how to mount a partition on USB storage. (See USB Storage)

Requirements

The scheme of mypage_scripts is:

mypage_scripts="</storage/www/mypage[1].sh> </storage/www/mypage[2].sh> ... </storage/www/mypage[n-1].sh> </storage/www/mypage[n].sh>"

Exchange storage with your underlying filesystem /jffs, /mmc, /mnt, ...

Currently there are nine scripts named mypage1.sh, ..., mypage9.sh.

Feel free to use only some of them. If this is the case set the order of mypage_scripts accordingly. Right now the filename is not important. Important is the order inside the mypage_scripts variable.

mypage1.sh is named Host.
This script shows different information about your device like device name, firmware, kernel version, memory, CPU and loaded kernel modules. All running processes since boot time are also displayed.

mypage2.sh is named Wireless.
This script shows wireless info like driver core, interface, status, version and capabilities. Single and dual band router are supported.

mypage3.sh is named Storage.
This script shows all information about the partition/disk in use like internal/external disks and flash. It also contains a backup feature for downloading CFE and NVRAM to a safe place on your computer.

mypage4.sh is named Network.
This script shows network related stuff like open ports, interfaces, routing table, arp table and domain name server.

mypage5.sh is named Filter.
This script shows the ip filter nat, log and nat2wan chains of your device.

mypage6.sh is named Kernel.
This scripts shows all the kernel messages emitted during the booting time of your device.

mypage7.sh is named NVRAM.
This scripts shows all the variables stored inside the NVRAM space of your device. The variables are sorted alphabetically.

mypage8.sh is named OPT.
This scripts shows all the installed and available software packages from OPTware on your device.

mypage9.sh is named Procs.
This scripts shows periodically all the top processes sorted by CPU and MEM of your device. This is an autorefresh page.

mypage10.sh is named Ports.
This scripts shows periodically all the open and established network ports of your device. This is an autorefresh page.

mypage11.sh is named Logs.
This scripts shows periodically the last 20 lines of syslogd kernel and user messages of your device. This is an autorefresh page.

Download

This files are stored inside the forum pages:

mypage-files-v0.12-20100107-00251.tgz
mypage-shots-v0.12-20100107-00251.tgz

Please download it from the My Page thread to /opt/www

Installation

Download the tgz file from the download section and find a useful place where to store it. In my case I store the file under /opt/www. This directory is a symlink to /jffs/opt/www. Choose whatever directory you like, don't forget to choose a persistent partition that survive a device reboot. Don't use /tmp, because it is a volatile RAM area.

You can choose another place, depending which filesystem you own. (SD,MMC,USB,CIFS)

Go to /opt/www and extract the file with:

tar -xvzf mypage-files-v0.12-20100107-00251.tgz .

Set the read flags for all files with:

chmod 644 *

Set the executable flags for all sh- and asp files

chmod 755 *.sh *.asp 

Root must own the files with:

chown root.root *

In your target directory there must be the following files:

root@rtgate01:/opt/www# ls -las
   0 drwx------      2 root     root              0 Jan  7 15:06 .
   0 drwxr-xr-x    16 root     root              0 Jan  7 14:31 ..
   1 -rw-r--r--     1 root     root          1403 Jan  7 08:53 mypage.css
   0 -rwxr-xr-x    1 root     root            119 Jan  5 09:26 mypage.live.asp
   5 -rw-r--r--     1 root     root          4784 Jan  7 14:20 mypage.log
 16 -rwxr-xr-x    1 root     root        15885 Jan  7 13:14 mypage1.sh
 10 -rwxr-xr-x    1 root     root        10566 Jan  7 13:36 mypage10.sh
 11 -rwxr-xr-x    1 root     root        10963 Jan  7 13:57 mypage11.sh
 12 -rwxr-xr-x    1 root     root        12401 Jan  7 13:14 mypage2.sh
 12 -rwxr-xr-x    1 root     root        12386 Jan  7 13:14 mypage3.sh
 12 -rwxr-xr-x    1 root     root        12376 Jan  7 13:14 mypage4.sh
 14 -rwxr-xr-x    1 root     root        14669 Jan  7 13:13 mypage5.sh
 10 -rwxr-xr-x    1 root     root        10427 Jan  7 13:13 mypage6.sh
 11 -rwxr-xr-x    1 root     root        11461 Jan  7 13:13 mypage7.sh
 12 -rwxr-xr-x    1 root     root        11824 Jan  7 13:13 mypage8.sh
 10 -rwxr-xr-x    1 root     root        10115 Jan  7 13:36 mypage9.sh
   4 -rw-r--r--    1 root     root          3626 Jan  7 14:53 mypage_common.js
   8 -rw-r--r--    1 root     root          7838 Jan  7 13:47 mypage_english.js
   8 -rw-r--r--    1 root     root          7970 Jan  7 13:47 mypage_german.js
 28 -rw-r--r--    1 root     root        28268 Jan  6 10:00 mypage_ip_english.png
 28 -rw-r--r--    1 root     root        28392 Jan  6 10:00 mypage_ip_german.png

Don't forget to symbolic link /opt/www to /tmp/www (See below)

root@rtgate01:/tmp# ls -las
  0 drwxrwxrwx    7 root     root            0 Jan  5 14:47 .
  0 drwxr-xr-x    16 root     root        162 Jan  2 12:29 ..
  4 -rw-r--r--       1 root     root      2024 Jan  5 12:19 .ipt
  4 -rw-r--r--       1 root     root            6 Jan  4 23:06 .megc
  4 -rw-r--r--       1 root     root            1 Jan  1  1970 .nas
  4 -rw-r--r--       1 root     root          20 Jan  5 12:19 .rule
  4 -rw-r--r--       1 root     root            9 Jan  4 17:39 .wanuptime
  0 drwx------      2 root     root            0 Jan  4 17:39 cron.d
  4 -rw-r--r--       1 root     root            0 Jan  5 12:19 crontab
  4 -rw-r--r--       1 root     root        237 Jan  4 17:40 dnsmasq.conf
  4 -rw-r--r--       1 root     root          47 Jan  4 17:42 dnsmasq.leases
  0 drwx------      2 root     root            0 Jan  1  1970 etc
  4 -rw-r--r--       1 root     root          41 Jan  4 17:40 hosts
  4 -rw-r--r--       1 root     root        237 Jan  4 17:39 igmpproxy.conf
  4 -rw-r--r--       1 root     root          86 Jan  1  1970 loginprompt
  4 -rw-r--r--       1 root     root            4 Jan  1  1970 nas.wl0lan.pid
  0 drwxr-xr-x     3 root     root             0 Jan  1  1970 oet
  4 -rw-r--r--       1 root     root          41 Jan  4 17:40 resolv.conf
  4 -rw-r--r--       1 root     root          23 Jan  4 17:40 resolv.dnsmasq
  0 drwx------      3 root     root            0 Jan  1  1970 root
  0 lrwxrwxrwx     1 root     root            8 Jan  1  1970 udhcpc -> /sbin/rc
  4 -rw-r--r--       1 root     root            6 Jan  1  1970 udhcpc.expires
  0 drwxr-xr-x    10 root     root            0 Jan  1  1970 var
  0 lrwxrwxrwx 1 root    root           8 Jan 1 1970 www -> /opt/www
NOTE: In this example I use /opt/www, feel free to use a different directory instead.
In this case reference everything to this directory. This directory must be persistent!
It must survive a reboot of your device!

Configuration

To set the nvram variable login into your device using telnet or ssh and at the command line execute:

nvram set mypage_scripts="/opt/www/mypage1.sh /opt/www/mypage2.sh /opt/www/mypage3.sh /opt/www/mypage4.sh /opt/www/mypage5.sh /opt/www/mypage6.sh /opt/www/mypage7.sh /opt/www/mypage8.sh /opt/www/mypage9.sh /opt/www/mypage10.sh /opt/www/mypage11.sh"

Don't forget to make the changes persistent with:

nvram commit

The script order is important. It can be called with http://192.168.1.1/MyPage.asp?1, ..., http://192.168.1.1/MyPage.asp?11

With version 0.9 theme and national language support (NLS) is available. All the DD-WRT themes are supported. Currently only english and german translation is available.

Everyone who are able and willing to translate, are kindly requested to contact me (gi-minni).

With NLS there is a need to have a symbolic link from the place where you stored the files to /tmp/www and a startup script that mount this place to /tmp/www after every reboot.

To test it the first time manually, please do:

# Link /opt/www to /tmp/www for mypage i18n support
if [ -d /tmp/www ]; then rm -rf /tmp/www; fi
ln -s /opt/www /tmp/www

In the /etc/config directory store a startup script named opt.startup

I use /jffs because my device (ASUS RT-N16) has enough space to store things inside the flash partition.

#!/bin/ash
# Mount /jffs/opt to /opt
if [ -d /jffs/opt ]; then mount -o bind /jffs/opt /opt; fi
# Link /opt/www to /tmp/www for mypage i18n support
if [ -d /tmp/www ]; then rm -rf /tmp/www; fi
ln -s /opt/www /tmp/www

Please pay attention that the above script is suited for jffs partitions. Change it for other partition type accordingly.

Navigation

Every page can have different display blocks. Depending on the amount and content of this display blocks. The displayed blocks can exceed the display region of your screen. For some pages this is true and scrolling will be inevitable.

Another bad thing is that autorefreshing a long page without using AJAX/Javascript will position the page to the top again, loosing the ability to watch a display block repeatedly.

I coded three navigation buttons. This are named top, refresh and goto:

^ (top) = If this button is pressed the page is displayed from the top
o (refresh) = If this button is pressed a manual page refresh is done
> (goto) = If this button is pressed the actual block is showed.

You will see a positive effect, e.g. on the host and log page.

On the host page you can press the goto button from the help menu and you jump directly to the specific display block.

On the log page you can see the user logs, by pressing the goto button. Every subsequent refreshes lock the page to the specific display block.

FAQ

Q: Is MyPage hardware dependent?
A: Mypage is hardware independent. It rely heavily on the javascript dd-wrt libraries, nvram program and on generic linux commands. Every router that is supported by dd-wrt can use Mypage without problem
Q: What firmware build do I need at least?
A: Mypage support was implemented at the end of November 2009. This require at least firmware build svn13309
Q: How can I open the newly installed pages?
A: To see the newly installed pages you must call the Status Router tab first. If you don't  see a tab called My Page, then please download and upgrade your router firmware to the latest level. Afterwards click on My Page and all defined subpages are showed.
Q: Why are all pages blank?
A: Ensure that all the mypage[1-9].sh, mypage.live.asp files have the execution flags set. chmod +x mypage*.sh mypage*.asp

Links

Screenshots

Here I stored all the screenshots. Feel free to post your comments & suggestions.

mypage0.sh - (Status information page)
mypage0.sh - (Status information page)
mypage1.sh - (Host device information page)
mypage1.sh - (Host device information page)
mypage2.sh - (Wireless information page)
mypage2.sh - (Wireless information page)
mypage3.sh - (Storage information page)
mypage3.sh - (Storage information page)
mypage4.sh - (Network information page)
mypage4.sh - (Network information page)
mypage5.sh - (IP Network Filter page)
mypage5.sh - (IP Network Filter page)
mypage6.sh - (Kernel messages page)
mypage6.sh - (Kernel messages page)
mypage7.sh - (NVRAM variables page)
mypage7.sh - (NVRAM variables page)
mypage8.sh - (OPT packages page)
mypage8.sh - (OPT packages page)
mypage9.sh - (Top running processes page)
mypage9.sh - (Top running processes page)
mypage10.sh - (Open & established ports page)
mypage10.sh - (Open & established ports page)
mypage11.sh - (Syslogd kernel & user page)
mypage11.sh - (Syslogd kernel & user page)

Changelog

v0.12-20100107-00251
[ADD] Show the last 20 user and kernel log entries - gi-minni
[ADD] New log page created - gi-minni
[ADD] Go to an refresh navigation added to legend - gi-minni
[ADD] Cron table in host page added - gi-minni
[CHG] Memory info in host page changed - gi-minni
[ADD] Routerboard information to host page added - gi-minni
[ADD] NVRAM size and free space to NVRAM page added - gi-minni
[ADD] Bridge interface to network page added - gi-minni
[CHG] Help navigation to each display block changed - gi-minni
[ADD] Legend navigation to top of each page added - gi-minni
[ADD] lan2wan and log filter chains added - gi-minni
[ADD] Chain images added - gi-minni
[ADD] IP filter and NAT table added - gi-minni
[ADD] New IP filter page created - gi-minni
[CHG] Only top 20 processes listed - gi-minni
[ADD] Established network port support added - gi-minni
[CHG] Pagetitle is dynamic and language dependent - gi-minni
[ADD] MyPage forum link added - gi-minni
v0.11-20100105-00213
[ADD] Top processes live page added - gi-minni
[ADD] Netstat live page added - gi-minni
[CHG] ASP files renamed to sh - gi-minni
[ADD] Dualband support added - gi-minni
[ADD] Live update support with mypage.live.asp added - gi-minni
[CHG] css statements refactored into mypage.css - gi-minni
[BUG] arp -a changed to arp, cmd take to long to complete - gi-minni
[BUG] opt ifconfig does not work, internal do - gi-minni
[CHG] WLAN pagename changed to Wireless again - gi-minni
[ADD] MyPage wiki link added - gi-minni
[ADD] MyPage download link added - gi-minni
v0.10-20091227-00185
[CHG] Every help header has a link to it's fieldset - gi-minni
[CHG] Help can include hyperlink - gi-minni
[CHG] Host and device are limited to 17 chars each - gi-minni
[CHG] Due to space constraints mypage is rearranged 1 level up - gi-minni
[ADD] Forum search added to the essential links - gi-minni
[CHG] Flash- and diskblock position rearranged in storage page - gi-minni
[ADD] Backup NVRAM download button added in storage page - gi-minni
[ADD] Backup CFE download button added in storage page - gi-minni
v0.9-20091224-00167
[ADD] Added One german and one english javascript file - gi-minni
[ADD] Added common javascript file - gi-minni
[ADD] Added German and English translations - gi-minni
[ADD] Every page is NLS aware - gi-minni
[CHG] Choosed Monospace font for a sharper view - gi-minni
[CHG] Rearrangements stuff in main page - gi-minni 
[CHG] Download file link adjusted to callback url - gi-minni
[ADD] Theme depends from nvram variable router_style - gi-minni
[ADD] Language depends from nvram variable language - gi-minni
[ADD] Add device to the info header and also into the main page - gi-minni
v0.8-20091223-00047
|ADD] Added date to the info header - gi-minni
[ADD] Added ARP Table to network page - gi-minni
[ADD] Added router database link - gi-minni
[ADD] Hostname added to the info header - gi-minni
[ADD] Started to add language support to the refresh button - gi-minni
[ADD] Autorefresh WAN IP enabled in the header - gi-minni
[ADD] Autorefresh uptime enabled in the header - gi-minni
[ADD] dd-wrt about page added in the header - gi-minni
[CHG] corrected various typos & bugs - gi-minni
v0.7-20091222-00037
[ADD] Added relevant dd-wrt and svn links - gi-minni
[CHG] Help information can display multiple links - gi-minni
[ADD] Version information is showed on each page - gi-minni
[ADD] Added inline stylesheet version - gi-minni
[ADD] New OPT page shows the installed and available opt packages - gi-minni
v0.6-20091221-00033
[ADD] Help information provided with notes and links - gi-minni
[ADD] inline stylesheet added with note and also style - gi-minni
v0.5-20091221-00021
[CHG] Pages are rendered in standard compliance mode (no quirks mode) - gi-minni
[CHG] Page suffix changed to asp - gi-minni
[ADD] Driver capabilities is wrapped as token for correct alignment - gi-minni
[CHG] Wireless info depends on interface read from nvram variable - gi-minni
[ADD] Help information is showed on each page - gi-minni
[ADD] Flash information on storage page - gi-minni
[CHG] Every wrapped lines is marked with the raquo symbol - gi-minni
v0.4-20091220-00015
[DEL] Uptime information removed from every page - gi-minni
[ADD] Header info reflect actual design - gi-minni
[ADD] HTML pagetitle reflect actual design - gi-minni
[ADD] Routing table added to network page - gi-minni
[ADD] Domain name server added to network page - gi-minni
[ADD] Kernel page added and wrapped at pos 75 for correct alignment - gi-minni
[ADD] NVRAM page added and wrapped at pos 75 for correct alignment - gi-minni
v0.3-20091220-00010
[ADD] netstat is cutted at pos 75 for correct alignment - gi-minni
[ADD] process list is wrapped at pos 75 for correct alignment - gi-minni
[NEW] initial version - gi-minni