Posted: Fri Oct 16, 2009 15:46 Post subject: Storing autoap.sh in NVRAM on V24_SP2 Standard
I have been running autoap.sh from nvram on V24_sp2 standard. Here is what I did if anyone would like to give it a try.
Download the autoap.sh file and open it on your pc. Now shrink it to as small as possible. Remove all comments, extra spaces, and blank lines. I also removed the code to read the nvram variable from the first function. If you are careful you can get the file to less than 11k. Check your available nvram (nvram show) to confirm your text is going to fit before proceeding. If the file is too big you will brick your router.
Replace the 4 special characters \,$,&," with \\,\$,\&,\". Make sure you start with \ so the other replaces are not messed up.
Add the nvram set and commit to the start and end of the file. Your file should look somethink like this:
Code:
nvram set autoap-code="
#!/bin/sh
aap_aplimit=20
aap_checkfreq=2
.....rest of code....
[ \"\$(nvram get autoap_rescannow)\" -gt 0 ] && aap_varupdate && no_ap=0
done
"
nvram commit
Copy and paste your text into either the telnet or ssh command line.
I know this is an old thread, but it really did solve all of my problems I was having with AutoAP. I no longer have to wait for the router to find an AP to auto-download the script, or mess with Samba, or install an SD card for JFFS. I don't have to deal with loading old or gimped firmware, either. AutoAP just loads up from nvram and it's good to go. Here are a couple notes from my experience:
1) For some reason, it gets hung up when looking for nvram 'autoap_' variables you set via the command line (the OP mentioned this briefly). So I just erased the 'aap_varupdate' function from the script, as well as the two places it is called on later in the script. The function itself is the very first one and looks like:
aap_varupdate ()
{
... code ...
}
With that gone, now if I need to change an autoap variable, I have to do so in the top part of the script itself, where all of the 'aap_...' vars are listed. After I change them, I do a 'nvram unset autoap-code' to clear autoap from nvram, then 'nvram show' to check free space, and then I do the 'nvram set autoap-code=" (...code...)' as per the original instructions.
2) Don't forget to get rid of all of the comments, which take up nearly half of the script. There are also a ton of unnecessary spaces in there; you can get rid of them by replacing all of the double spaces with singe spaces in your editor a few times until they are gone. You can also save space by taking long English phrases like "Successfully collected access point scan data, analysing..." and trimming them down to "APs found..." and so on.
3) The & characters should NOT be proceeded by a \. Just do the find/replace for all of the \, $, and " characters so they become \\, \$, and \" respectively.
4) Maybe someone out there can figure out a way to store a gzipped version of the script within a nvram variable, which could then be ungzipped and run from tmp at boot. I know somebody made it so you can gzip your firewall scripts, could that work for AutoAP as well?
So anyway, maybe it's not the most elegant solution in the world, but it works for me and my WRT54GL. I don't know what the rules are for posting edited scripts, so I'm not going to post my trimmed down version unless I get the go ahead. Besides, I don't know what bugs are lurking in it, and I can't be doing tech support on something I barely understand.