It sounded a bit condescending, but it wasn't meant that way at all....
It's just that I already know that if I explain one thing, you'll have even more questions and still have no results....
But anyhow...
I'll try.
Your router can run scripts written in bash. So-called shell scripts.
The script I wrote should be saved in the router together with the 2nd file called "vars_to_skip".
In Linux you can execute a script by giving it the "executable-flag" and enter its name with its path.
You can give a file an executable-flag by issuing the command.
Code:
chmod +x <filename>
The first pitfall for a windows user is to just give the name whilst you are in that same directory. It will NOT execute it. You have to precede it with ./
It will only execute it if you give the exact location or it's in its path. To see your path enter "echo $PATH"
I have a router with USB-support and attached a USB-stick to it with an ext3-partition which I mounted as /opt. This makes things a lot easier.
If you don't have USB-support, you can enable jffs-space, create the directory /jffs/opt and mount it as /opt.
You will now have a proper framework to start working. Put the 2 files in /opt/usr/sbin and make them executable. You can do this with winSCP (google) after you enabled SSH and changed the preference in WinSCP to use SSH instead of SFTP.
Let me know how far you come this time....[/code] _________________ 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
Joined: 07 Jun 2006 Posts: 1476 Location: New York, USA
Posted: Sun Feb 01, 2009 16:34 Post subject:
Slione wrote:
frater wrote:
It sounded a bit condescending, but it wasn't meant that way at all....
I didn't take it that way at all. I can admit when I am beyond my limited capabilities but am always willing to learn. :)
Quote:
Let me know how far you come this time....
I will try this tomorrow and let you know the outcome. Thanks!
Frater
Can I make a suggestion here that might make this more universal??
First, many of the dd-wrt users are either running a build that has no room for a JIFFS file system or just dont have much Linux savvey.
My suggestion is to make a stand-alone version of your scripts that can be scp'd (usinf winscp) to /tmp on the router. This version would execute on /tmp and would create its output files in /tmp. These files would then be moved to the users PC - again using winscp.
To restore settings on a new router - simply scp the saved scripts to the /tmp dir on the router and execute them.
No ftp needed, no new directory structure, no additional file systems (CIFF, JIFF, usb, etc).
You can do it if you want to. _________________ 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
Step 4: Again using winscp on your PC (or your favorite scp client) copy those 3 files into a safe place on your PC
To restore settings on a reset DD-WRT do the following
1) enable ssh access (and telnet if you like)
2) using winscp copy tha appropriate backup file(s) to the /tmp dir on your router
3) using ssh (or telnet) log on to your router. Change directory (cd) to the /tmp directory.
# cd /tmp
Set execute permission on the backupvars.sh script as follows:
# chmod +x /tmp/*.sh
4) execute the appropriate script on the router
# ./MACADDRESS.DATE.all.sh
reboot and your done!!!!
Here is what you need to cut and paste into a file called backupvars.sh:
!/bin/sh
#
# This shell script creates a shell file with lines of the form
# nvram set x="y"
# for every nvram variable found from
# nvram show
#
DATE=`date +%m%d%Y`
MAC=`nvram get lan_hwaddr | tr -d ":"`
FILE=${MAC}.${DATE}
CUR_DIR=`dirname $0`
FOLDER=/tmp
TO_ALL=${FOLDER}/${MAC}.${DATE}.all.sh
TO_INCLUDE=${FOLDER}/${MAC}.${DATE}.essential.sh
TO_EXCLUDE=${FOLDER}/${MAC}.${DATE}.dangerous.sh
#FTPS=ftp://192.168.10.210/backups
#vUSERPASS=user:pass
nvram show 2>/dev/null | egrep '^[a-zA-Z].*=' | awk -F= '{print $1}' | grep -v "[ /+<>,:;]" | sort -u >/tmp/all_vars
#
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_ALL} > ${TO_INCLUDE}
cat /tmp/all_vars | while read var
do
if echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
bfile=$TO_EXCLUDE
else
bfile=$TO_INCLUDE
fi
# get the data out of the variable
data=`nvram get ${var}`
if [ "${data}" == "" ] ; then
echo -e "nvram set ${var}=" | tee -ia ${TO_ALL} >> ${bfile}
else
# 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 's/\\/\\\\/g' | sed 's/`/\\`/g' | sed 's/\$/\\\$/g' | sed 's/\"/\\"/g' | tee -ia ${TO_ALL} >> ${bfile}
echo -e "\"" | tee -ia ${TO_ALL} >> ${bfile}
fi
done
rm /tmp/all_vars
echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit" | tee -ia ${TO_ALL} | tee -ia ${TO_EXCLUDE} >> ${TO_INCLUDE}
chmod +x ${TO_ALL}
chmod +x ${TO_INCLUDE}
chmod +x ${TO_EXCLUDE}
Copy the following into a file called vars_to_skip
Not only a thanks to him but a thanks to you also Frater! Between your scripts and Dellsweig's instructions I have backed up my settings, installed the latest mega version (11536)on my WRT54G-TM router, reinstalled the backed up settings and it worked beautifully!
I only had one thing that did not work correctly and that is the MAC filtering under the Wireless tab. I Allow the users with MACs I've put in the Mac filter list and when the settings were restored it had the Prevent one selected. I tried restoring the settings on another router I have and it did the same thing. Is there something that it's not reading/writing properly?
does this script fail if a var has been added to the firmware or removed by BS or Eko ?
Also, what do I do with the 2 other .sh files that are created ? the one called dangerous and essential ? _________________ 1 WRT160N v3 - remote AP WPA2 Personal Aes dd-wrt-mini-trailed CPU OC400,
2 wrt54G v3(BCM4712 chip rev 1, corerev=7)- AP WPA2 Personal Aes dd-wrt-mini-generic CPU OC228,
1 wrt54gs v6 - remote AP WPA2 Personal Aes dd-wrt-micro CPU OC228 ,
3 WAP54g v3 - repeater, client Bridge, repeater bridge dd-wrt-micro CPU OC225,
1 NetGear WNR2000 v3 AP Atheros AR7241 ver 1 rev 1.1 (0x0101) Trailed build CPU OC360
DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
does this script fail if a var has been added to the firmware or removed by BS or Eko ?
Also, what do I do with the 2 other .sh files that are created ? the one called dangerous and essential ?
No, the script itself doesn't.
If a var is removed by Brainslayer it will re-appear, which is not a real problem as that var will not be used by the software. It takes however some memory from the var-environment. I could change the script to check for that.
If a var is added by Brainslayer this var will be created anyhow by Brainslayer's initialisation code (defaults.c) . _________________ 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
Not only a thanks to him but a thanks to you also Frater! Between your scripts and Dellsweig's instructions I have backed up my settings, installed the latest mega version (11536)on my WRT54G-TM router, reinstalled the backed up settings and it worked beautifully!
I only had one thing that did not work correctly and that is the MAC filtering under the Wireless tab. I Allow the users with MACs I've put in the Mac filter list and when the settings were restored it had the Prevent one selected. I tried restoring the settings on another router I have and it did the same thing. Is there something that it's not reading/writing properly?
Other than that it is great!!
Can you check if the MAC-addresses were in the .sh file? Did you use "essential"?
If you used "essential" can you check if they were in "all"? Please give the name of the var where they were in.
It's possible the script puts these MACs in "dangerous". If so, this is wrong. _________________ 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
Step 1: on your PC - use winscp to copy backupvars.sh and vars_to_skip to your routers /tmp directory
step 2: using ssh (or telnet) log on to your router. Change directory (cd) to the /tmp directory.
# cd /tmp
Hi,
First of all a big thank you to both frater and dellsweig for providing us with this wealth of information!
Please bare with me, as I'm completely illiterate in linux stuff!
I have a couple of questions on all of this:
1) Just wondering can I do all of this even on a micro version, or do I need as minimum the mini version of DD-WRT? I'm currently using micro build 11650 VINT EKO on a WRT54G v1.1 router.
2) I downloaded WinSCP (the latest beta version 4.2.1), but I can't figure out which of the options in the SSH tab I need to configure to get connected to the router.
3) When logging in with WinSCP, am I correct in assuming that in "host name" I type in the ip of the router? Do I use the standard "root" (like when using telnet) as "user name"? Do I need a "private key file"?
Your assistence will be greatly appreciated! Many thanks.
what are the other 2 .sh files supposed to be used for ? instructions said to restore ALL, but there is also essential and dangerous which is empty. _________________ 1 WRT160N v3 - remote AP WPA2 Personal Aes dd-wrt-mini-trailed CPU OC400,
2 wrt54G v3(BCM4712 chip rev 1, corerev=7)- AP WPA2 Personal Aes dd-wrt-mini-generic CPU OC228,
1 wrt54gs v6 - remote AP WPA2 Personal Aes dd-wrt-micro CPU OC228 ,
3 WAP54g v3 - repeater, client Bridge, repeater bridge dd-wrt-micro CPU OC225,
1 NetGear WNR2000 v3 AP Atheros AR7241 ver 1 rev 1.1 (0x0101) Trailed build CPU OC360
DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
All - All variables
Dangerous - Variables that are hardware specific and should not be loaded on another router. These variables will be created by the firmware anyhow.
Essential - These variables are safe to load.
Do you have "vars_to_skip" in the same directory? _________________ 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