#########################################################
#FTP Login information change to your info
#########################################################
#########################################################
#create NVRAM variale list and write to /opt/tmp/all_vars
#########################################################
#########################################################
# Write header to restore scripts
#########################################################
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_PREFERRED} | tee -i ${TO_ALL} > ${TO_INCLUDE}
#########################################################
# scan NVRAM variable list and send variable to proper
# restore script
#########################################################
cat ${VARFILE} | while read var
do
pref=0
if echo "${var}" | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
bfile=$TO_EXCLUDE
else
bfile=$TO_INCLUDE
pref=`echo "${var}" | grep -cf "${CUR_DIR}/vars_preferred"`
fi
# get the data out of the variable
data=`nvram get ${var}`
# write the var to the file and use \ for special chars: (\$`")
echo -en "nvram set ${var}=\"" | tee -ia ${TO_ALL} >> ${bfile}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' | tee -ia ${TO_ALL} >> ${bfile}
echo -e "\"" | tee -ia ${TO_ALL} >> ${bfile}
if [ ! ${pref} == 0 ]; then
echo -en "nvram set ${var}=\"" >> ${TO_PREFERRED}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' >> ${TO_PREFERRED}
echo -e "\"" >> ${TO_PREFERRED}
fi
done
#########################################################
# Write footer to restore script
#########################################################
echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit" | tee -ia ${TO_ALL} | tee -ia ${TO_PREFERRED} | tee -ia ${TO_EXCLUDE} >> ${TO_INCLUDE}
#########################################################
# Change permissions on restore scripts to make them
# executable
#########################################################
#########################################################
# Compress restore scripts and send them to ftp server
#########################################################
i added comments to what i believe to be a good working script check it out and let me know what should be added this way other people can understand the script better.
Last edited by hardwarewizard on Sun Jul 26, 2009 1:45; edited 1 time in total
I just used your information to upgrade my Linksys WRT150N Router to build 12533. Even with a significant amount of double checking it took me less than an hour.
Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Sat Jul 25, 2009 14:13 Post subject:
rcblackwell wrote:
dellsweig wrote:
frater wrote:
Well, I agree...
You can do it if you want to.
No problem - here is what I have done........
frater / dellsweig,
I just used your information to upgrade my Linksys WRT150N Router to build 12533. Even with a significant amount of double checking it took me less than an hour.
Thank you for your contribution in this regard.
Bob Blackwell
Pickering, On
Yes, I know it's been said over and over again, but Thanks from the Shadow. _________________ The New Me
Joined: 15 Apr 2007 Posts: 200 Location: Buffalo, NY
Posted: Sun Jul 26, 2009 0:54 Post subject:
crashfly wrote:
Yes. If you can figure this one out, we would be much appreciated.
Although I can imagine a way to possibly test it. Re-establish the variables (possibly after a hard reset), then change that particular option and rerun the backup program to see what (if anything has changed).
i believe i have figured it out the wl_ variables over write the wl0_ variables
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sun Jul 26, 2009 2:03 Post subject:
I wonder if it would be possible to figure out a way to make the wl_variables get written to first, then write the wl0_variables in this script. I know it is not *that* complicated, but that might be something worth looking into.
Edit: I have looked at the 'results' of the script. It appears that wl0 is written first, then wl1 and finally wl variables. I will consider switching them around on my "next" test upgrade and see if this fixes the problem. _________________ E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]
Try Dropbox for syncing files - get 2.5gb online for free by signing up.
Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
It doesn't matter at all in which order these variables are written. Nothing is being done with these variables until the services that need them are restarted (so I'm convinced until you show me the contrary). You also need to reboot the router after writing.
The reason why I sort them (alphabetically) is that I can do a diff and see what variables have been changed.
I know that using this script is not without any issues but I'm convinced the reason is DD-WRT itself.
After I factory-default my router and restore the settings with my script I always have to turn off WDS and turn it on afterwards to get it going. I have no physical access to my WAN-router, so this is cumbersome process. I would like to make this an entry in TRAC but I'm sure the ticket will get closed leaving my script to blame.
I stopped investigating it and just change my WDS-bridge in a client-bridge and change these settings manually. I will investigate it another time the next time I will do an upgrade (using diff to compare the vars before and after getting WDS going.) _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
I just saw the entry you made in TRAC.
It seems the command "nvram set" is doing more than just set that particular variable...
Not the right place to keep those 2 variables in sync. It's probably been done as a quick and dirty fix after they started supporting multiple wireless interfaces.
The remark I made in my previous post is still valid, but it doesn't take this kind of programming into account. I hate it when commands do other things than they say. I used to have the sources on my linux system but that didn't survive a harddisk crash.
I will now look into an elegant way to write the wl_ variables first. A quick-and-dirty way would be to use sort -r -u instead of sort -u. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
#########################################################
#FTP Login information change to your info
#########################################################
#########################################################
#create NVRAM variale list and write to /opt/tmp/all_vars
#########################################################
#########################################################
# Write header to restore scripts
#########################################################
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_PREFERRED} | tee -i ${TO_ALL} > ${TO_INCLUDE}
#########################################################
# scan NVRAM variable list and send variable to proper
# restore script
#########################################################
cat ${VARFILE} | while read var
do
pref=0
if echo "${var}" | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
bfile=$TO_EXCLUDE
else
bfile=$TO_INCLUDE
pref=`echo "${var}" | grep -cf "${CUR_DIR}/vars_preferred"`
fi
# get the data out of the variable
data=`nvram get ${var}`
# write the var to the file and use \ for special chars: (\$`")
echo -en "nvram set ${var}=\"" | tee -ia ${TO_ALL} >> ${bfile}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' | tee -ia ${TO_ALL} >> ${bfile}
echo -e "\"" | tee -ia ${TO_ALL} >> ${bfile}
if [ ! ${pref} == 0 ]; then
echo -en "nvram set ${var}=\"" >> ${TO_PREFERRED}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' >> ${TO_PREFERRED}
echo -e "\"" >> ${TO_PREFERRED}
fi
done
#########################################################
# Write footer to restore script
#########################################################
echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit" | tee -ia ${TO_ALL} | tee -ia ${TO_PREFERRED} | tee -ia ${TO_EXCLUDE} >> ${TO_INCLUDE}
#########################################################
# Change permissions on restore scripts to make them
# executable
#########################################################
#########################################################
# Compress restore scripts and send them to ftp server
#########################################################
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
#########################################################
#FTP Login information change to your info
#########################################################
#########################################################
#create NVRAM variale list and write to /opt/tmp/all_vars
#########################################################
#########################################################
# Write header to restore scripts
#########################################################
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_PREFERRED} | tee -i ${TO_ALL} > ${TO_INCLUDE}
#########################################################
# scan NVRAM variable list and send variable to proper
# restore script
#########################################################
cat ${VARFILE} | while read var
do
pref=0
if echo "${var}" | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
bfile=$TO_EXCLUDE
else
bfile=$TO_INCLUDE
pref=`echo "${var}" | grep -cf "${CUR_DIR}/vars_preferred"`
fi
# get the data out of the variable
data=`nvram get ${var}`
# write the var to the file and use \ for special chars: (\$`")
echo -en "nvram set ${var}=\"" | tee -ia ${TO_ALL} >> ${bfile}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' | tee -ia ${TO_ALL} >> ${bfile}
echo -e "\"" | tee -ia ${TO_ALL} >> ${bfile}
if [ ! ${pref} == 0 ]; then
echo -en "nvram set ${var}=\"" >> ${TO_PREFERRED}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' >> ${TO_PREFERRED}
echo -e "\"" >> ${TO_PREFERRED}
fi
done
#########################################################
# Write footer to restore script
#########################################################
echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit" | tee -ia ${TO_ALL} | tee -ia ${TO_PREFERRED} | tee -ia ${TO_EXCLUDE} >> ${TO_INCLUDE}
#########################################################
# Change permissions on restore scripts to make them
# executable
#########################################################
#########################################################
# Compress restore scripts and send them to ftp server
#########################################################
You might want to add a command line switch to enable/disable the last section (tar and ftp).
many of us have either a samba share or usb filesystem where we dont need to ftp. On the boxes that dont, I prefer to use winscp and manually move the restore files to a safe location.
Finally, you should check with Eko or one of the keepers of DD-WRT - maybe you can get this script added to the download section. This script has saved my rear more times than I can count.
You might want to add a command line switch to enable/disable the last section (tar and ftp).
many of us have either a samba share or usb filesystem where we dont need to ftp. On the boxes that dont, I prefer to use winscp and manually move the restore files to a safe location.
Nothing's easier than leaving that last bit off when you add it to your router....
dellsweig wrote:
Finally, you should check with Eko or one of the keepers of DD-WRT - maybe you can get this script added to the download section. This script has saved my rear more times than I can count.
I can't get in touch with Brainslayer nor Eko. When I write them I get no response at all, anymore. I'd like to get my reverse-proxy added to the firmware, Large File Support for busybox and a standard startup-script for /opt/etc/init.d (I now have to use valuable nvram to accomplish that). That's my priority list in a nutshell.... _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
#########################################################
#FTP Login information change to your info
#########################################################
FTPS=ftp://192.168.10.210/backups
USERPASS=user:pass
transfer=0
while getopts tu:f: name
do
case $name in
t) transfer=1;;
u) USERPASS="$OPTARG";;
f) FTPS="$OPTARG";;
?) printf "Usage: %s: [-t] [-u username:password] [-f ftpserver]\n" $0
exit 2;;
esac
done
shift $(($OPTIND - 1))
#########################################################
#create NVRAM variale list and write to /opt/tmp/all_vars
#########################################################
#########################################################
# Write header to restore scripts
#########################################################
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_PREFERRED} | tee -i ${TO_ALL} > ${TO_INCLUDE}
#########################################################
# scan NVRAM variable list and send variable to proper
# restore script
#########################################################
cat ${VARFILE} | while read var
do
pref=0
if echo "${var}" | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
bfile=$TO_EXCLUDE
else
bfile=$TO_INCLUDE
pref=`echo "${var}" | grep -cf "${CUR_DIR}/vars_preferred"`
fi
# get the data out of the variable
data=`nvram get ${var}`
# write the var to the file and use \ for special chars: (\$`")
echo -en "nvram set ${var}=\"" | tee -ia ${TO_ALL} >> ${bfile}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' | tee -ia ${TO_ALL} >> ${bfile}
echo -e "\"" | tee -ia ${TO_ALL} >> ${bfile}
if [ ! ${pref} == 0 ]; then
echo -en "nvram set ${var}=\"" >> ${TO_PREFERRED}
echo -n "${data}" | sed -e 's/[$`"\]/\\&/g' >> ${TO_PREFERRED}
echo -e "\"" >> ${TO_PREFERRED}
fi
done
#########################################################
# Write footer to restore script
#########################################################
echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit" | tee -ia ${TO_ALL} | tee -ia ${TO_PREFERRED} | tee -ia ${TO_EXCLUDE} >> ${TO_INCLUDE}
#########################################################
# Change permissions on restore scripts to make them
# executable
#########################################################
#########################################################
# Compress restore scripts and send them to ftp server
#########################################################
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
I can't get in touch with Brainslayer nor Eko. When I write them I get no response at all, anymore. I'd like to get my reverse-proxy added to the firmware, Large File Support for busybox and a standard startup-script for /opt/etc/init.d (I now have to use valuable nvram to accomplish that). That's my priority list in a nutshell....
I didn't forget it... just no time to do it and it's summer.....
I didn't forget it... just no time to do it and it's summer.....
Okay....
Well... "No" or "Not yet" is a reply too as I always say... _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge