#### More tricks #### --------------------------------------------------------------------------------------------------------------------------- An alternative way to make a SDcard with minimum writes (to save the card) I use 2 SDcards, while one is in the wapserver, I can modify the other. A reboot from the wapserver takes about 12 seconds, writing an image of 1GB to a slow SDcard via an USB-1 programmer takes almost an hour (49 minutes last time I tried).. I am using the cheapest SDcards I could get. To reduce the number of writes to the SDcard when first loading it with a full 1 GB website, I write to a file first, then copy the file to the card (no so directory access cycles happen for each file as in ext2). This probably makes only sense for a NEW empty card and a BIG website. Because it takes so long to upload 1GB to the card every time you make a change .... dmesg: SCSI device sda: 1950720 512-byte hdwr sectors (999 MB) Make sure enough disk space on target (my target is /mnt/hdd4, likely DIFFERENT in your case: df /mnt/hdd4 38571552 33366008 5205544 87% / # Create empty image the size of the SDcard (big blocksize is faster the blocksize 512 and many blocks): dd if=/dev/zero of=/mnt/hdd4/sdimage bs=1950720 count=512 # create ext2 filesystem on image: mke2fs /mnt/hdd4/sdimage sdimage is not a block special device. Proceed anyway? (y,n) y # mount the image: mkdir /mnt/test mount sdimage /mnt/test -o loop # Check if properly mounted: mount #should show among other stuff: # /dev/loop0 on /mnt/test type ext2 (rw) # go to image cd /mnt/test # Create the Linksys wapserver files: cp wapserver-0.3.tgz ./ tar -zxvf wapserver-0.3.tgz # Should give: # grml: /mnt/test # ls # linksys/ lost+found/ wapserver-0.3.tgz # Now create your website (or copy it from wherever it was) on /mnt/test # Test first with local webserver.... cp * -rf /usr/local/httpd/htdocs/* /mnt/test/ # edit website as required (it may differ from original, we have no PHP (yet??): # unmount the created image # leave /mnt/test so we can umount cd # un mount the loop device umount /dev/loop0 # loop devices stay busy sometimes, free it so we can mount the same again: losetup -d /dev/loop/0 # Now insert SDcard in PC and type 'dmesg' until it is recognised, something like: # ...... # SCSI device sda: 1950720 512-byte hdwr sectors (999 MB) # ...... # usb-storage: device scan complete # Note: Here the card is detected as /dev/sda THIS MAY DIFFER ON YOUR SYSTEM, I use sda in the following example, # using the wrong device may wipe your system!!!: # Now transfer the image to the SDcard, the card is NOT mounted, only ONE write for each memory location in the card! dd if=/mnt/hdd4/sdimage of=/dev/sda Now lets see, that took 49 minutes. The number of bits is: 1950720 x 512 x 8 = 7990149120 The time in seconds is: 49 x 60 = 2940 Bits per second was 7990149120 / 2940 = 2 717 737.796 = 2.7 MBits / second write speed. 300 kBytes / second, not bad at all, still below USB-1 speed.... --------------------------------------------------------------------------------------------------------------------------- Set date on wapserver # Via serial link: # Setting the date on the WAP (if your serial is on /dev/ttyS1, else /dev/ttyS0, and note the `` characters): q1=`/bin/date -u +%m%d%H%M%Y` echo date $q1 > /dev/ttyS1 # Via telnet: #!/bin/sh WAP=10.0.0.152 port=23 q1=`/bin/date -u +%m%d%H%M%Y` cmd="date $q1" ( echo open ${WAP} ${port} echo -e "\r" sleep 1 echo ${cmd} echo -e "\r" sleep 1 echo exit ) | telnet --------------------------------------------------------------------------------------------------------------------------- Control transmitter # Via serial link or telnet # setting wireless on or off: # Off: wl down # On: wl up # Ouput power: # default nvram set pa0maxpwr=72 nvram commit # I'v heard this can be set as high as 84? # for 1 mW wl txpwr1 -m 1 # for 255mW (the maximum) wl txpwr1 -m 255 # There is an override mode too, that overides regional limits (may be illegal in your country). wl txpwr1 -m 255 -o # Just type wl # for a list.... --------------------------------------------------------------------------------------------------------------------------- How to transfer files from the wapserver to the PC with telnet using netcat (nc): In this example the wapserver has IP 10.0.0.152, and the PC has IP 10.0.0.150, and we use port 83. wapserver any to PC: On PC: # in one xterm nc -l 10.0.0.152 -p 83 > bbox # in other xterm: # telnet to wapserver: telnet 10.0.0.152 cd /tmp/var/bon cat /mnt/linksys/busybox/busybox | ./nc 10.0.0.150 83 --------------------------------------------------------------------------------------------------------------------------- serial port script to daily grab the log and save it on the PC, clear the /var/log/messages # define this for your situation, minicom must be running or have set correct serial port parameters. SERIAL_PORT=/dev/ttyS1 PC=10.0.0.150 WAP=10.0.0.152 # Local: # PC listens, change path-filename for your situation, httpd log will be appended to this file: nc -l $WAP -p 83 >> /root/wap/wapserver-connects.txt & # executed remote on wapserver: # send ctrl C (octal 003) in case tail -f /var/log/httpd.log was running in minicom: echo -e \\\003 > $SERIAL_PORT # send log to PC echo "cat /var/log/httpd.log | ./nc $PC 83" > $SERIAL_PORT # remove old log to save space, a new one will automatically be created upon an httpd request: echo "rm /var/log/httpd.log" > $SERIAL_PORT --------------------------------------------------------------------------------------------------------------------------- How to transfer files from the PC to the wabserver with wget using telnet or serial link: In this example the wapserver has IP 10.0.0.152, and the PC has IP 10.0.0.150, and must run a webserver, and wget uses port 80 by default: # telnet to wapserver: telnet 10.0.0.152 # change to a writable directory: cd /tmp/..... wget 10.0.0.150/whatever ---------------------------------------------------------------------------------------------------------------------------