What's new

User NVRAM Save/Restore Utility (R26.2)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Status
Not open for further replies.
Well, I set up your same structure on an ext4 format partition and it still worked fine....so I'm still at a loss.

Line 2 and Line 5 are blank lines in the script....how did you transfer the files to the router? Any chance you accidentally edited the files under windows and changed the file format from Linux to DOS/WINDOWS (end of line LF vs CR/LF)?

no, I will try to download the script another time (third time ) and run it. I will post results

thanks!
 
no, I will try to download the script another time (third time ) and run it. I will post results

thanks!
Just as a double check, you may want to try to open the script in 'vi' on the router and make sure that the format looks correct.
 
FYI - Yes it is caused by DOS CR/LF. I've just tested it:
Code:
admin@RT-N66U:/tmp/mnt/VERBATIM/ASUS/nvram-save-r21# unix2dos nvram-save.sh

admin@RT-N66U:/tmp/mnt/VERBATIM/ASUS/nvram-save-r21# sh nvram-save.sh
: not foundsh: line 2:
: not foundsh: line 5:
nvram-save.sh: line 137: syntax error: unexpected word (expecting "in")

admin@RT-N66U:/tmp/mnt/VERBATIM/ASUS/nvram-save-r21# dos2unix nvram-save.sh

admin@RT-N66U:/tmp/mnt/VERBATIM/ASUS/nvram-save-r21# sh nvram-save.sh

nvram-save.sh: NVRAM User Save Utility - Version 21
nvram-save.sh: Saving settings from firmware 374.43_2-14E1j9527
nvram-save.sh: Using standard NVRAM variable file: nvram-merlin.ini
nvram-save.sh: Running in Backup Mode

Saving [System - Basic]
Saving [System - Miscellaneous]
Saving [Disk Utility]
Saving [Switch Control]
Saving [NAT Passthrough]
Saving [TCP/UDP Settings]
Saving [Port Forwards]
Saving [Port Triggers]
Looks like a bad unzip/copy to the router.
 
Last edited:
Thanks for the help!!!

BTW....dos2unix is an addon I put in my fork. It won't be available in the Merlin build he is running.

While @ryzhov_al once posted an awk one-liner that did a similar trick, it might be a good idea to add dos2unix to the firmware. I assume it's a BB applet that you enabled?
 
While @ryzhov_al once posted an awk one-liner that did a similar trick, it might be a good idea to add dos2unix to the firmware. I assume it's a BB applet that you enabled?
Yes sir.....BusyBox applet.....I also enabled 'uniq' since it's so handy to have around :)
 
Yes sir.....BusyBox applet.....I also enabled 'uniq' since it's so handy to have around :)

I'll add dos2unix, as it will make it much easier for people who are Windows-centric to fix their notepad-generated scripts. Just remind me during the 378.57 development process if you can't provide a pull request for it. I don't want to make any change beside bugfixes for the 378.56_2 release I'm currently working on.
 
Time for a refresh....Thanks to everyone for their feedback!

User NVRAM Save/Restore Utility
LATEST RELEASE: Release 22
27-October-2015
nvram-save-r22.zip
Download http://1drv.ms/16pENHc
===============================

Program Changes
  • Changes to facilitate the release of ini file only updates
    • Show version numbers with -v in addition to consistency check
    • Print ini version to syslog
    • Add ini version to runlog
  • Only set file permissions on non-FAT format drives
  • Update Merlin/Fork unique vars in exception processing
  • Update Quickstart guide with FAT32 info
INI file Changes
  • Fix IPv6 settings for non-native modes
  • Fix SMB/FTP access restore by adding index var
  • Add support for syslog logging level and msg level
  • Add support for reboot schedule
  • Additional support for 3 radios
  • Add support for up to 5 VPN servers/clients
  • Add support for QOS bw limiting
  • Add support for WTFast
  • Add support for KeyGuard
  • Update Merlin/Fork unique variables
 
  • Only set file permissions on non-FAT format drives
Really?
Code:
admin@RT-N66U:/tmp/mnt/VERBATIM/ASUS/nvram-save-r22# ./nvram-save.sh

nvram-save.sh: NVRAM User Save Utility - Version 22
nvram-save.sh: Saving settings from firmware 374.43_2-14E1j9527
nvram-save.sh: Using standard NVRAM variable file: nvram-merlin.ini Version=22
nvram-save.sh: Running in Backup Mode
chmod: /tmp/mnt/VERBATIM/ASUS/nvram-save-r22/nvram-all-20151028-78A8.txt: Operation not permitted

Saving [System - Basic]
Saving [System - Miscellaneous]
:
:
Saving [WTFast settings]
Saving [TOR VPN settings]
Saving [Astrill VPN settings]
chmod: /tmp/mnt/VERBATIM/ASUS/nvram-save-r22/nvram-usr-20151028-78A8.txt: Operation not permitted
chmod: /tmp/mnt/VERBATIM/ASUS/nvram-save-r22/nvram-restore-20151028-78A8.sh: Operation not permitted

nvram-save.sh: Complete: User NVRAM saved to /tmp/mnt/VERBATIM/ASUS/nvram-save-r22/nvram-restore-20151028-78A8.sh

cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/failover.sh': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/services-start': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/test.sh': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/wan-start': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/unmount': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/vsftpd.postconf': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/webmon_start.sh': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/post-mount': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/firewall-start': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/smb.postconf': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/webmon_backup.sh': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/adblock.sh': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/services-start.failover': Operation not permitted
cp: can't preserve permissions of '/tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8/./scripts/webmon_report.sh': Operation not permitted
nvram-save.sh: Complete: JFFS directory saved to /tmp/mnt/VERBATIM/ASUS/nvram-save-r22/jffs-20151028-78A8
 
OK. It's because I'm running the script from a subdirectory on the USB drive, not the root. So it's not matching the "mount" output.
Code:
# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/VERBATIM type vfat (rw,nodev,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=winnt,flush)
 
Yep...fooled me with your long path :)
Coding up a fix now.

Just uploaded a 'fixed' nvram-save-r22.zip....

To the 12 of you who jumped on the download, if you are running on fat formatted USB sticks with the scripts loaded to other than the root, you can download a fresh copy to eliminate the warning messages.

Thanks @ColinTaylor for the quick test!
 
Hi john9527,

I was using the r15 from a long time with no issue and decided to use the r22.
On my RTAC56U, I was unable to launch the nvram-save.sh script and I figured out why in the script.
I had to un-comment this:
#cwd=$(pwd)​
and comment this:
cwd=$(dirname $(readlink -f $0))​

I have no clue why my shell doesn't interpret correctly the $0.
Any idea? Otherwise I will implement a simple test to choose one of the other one depending of the result returned.

Thank you for your answer and continue the great work you have done so far on this. Very much appreciated
 
While @ryzhov_al once posted an awk one-liner that did a similar trick, it might be a good idea to add dos2unix to the firmware. I assume it's a BB applet that you enabled?

This is what I use along with a description (more for others than you).

Code:
tr -d '\r' < source.sh > dest.sh

Creates dest.sh by stripping carriage return characters from source.sh. This is useful to fix files with DOS line endings ( ^M ) (which can prevent scripts and configuration files from being correctly handled). You can determine whether a file suffers from DOS line endings by opening it with vi (using cat will not work).
 
Hi john9527,

I was using the r15 from a long time with no issue and decided to use the r22.
On my RTAC56U, I was unable to launch the nvram-save.sh script and I figured out why in the script.
I had to un-comment this:
#cwd=$(pwd)​
and comment this:
cwd=$(dirname $(readlink -f $0))​

I have no clue why my shell doesn't interpret correctly the $0.
Any idea? Otherwise I will implement a simple test to choose one of the other one depending of the result returned.

Thank you for your answer and continue the great work you have done so far on this. Very much appreciated
Linux is funny when it comes to executing things from the current directory (the current directory isn't automatically part of the path although it seems to work sometimes). Are you executing the script as

./nvram-save.sh

to specify the current directory?
 
You are correct I am not specifying any directory when I launch the script expecting it will take the current directory.
it seems $0 returns nothing or "-sh" reason why I need to substitute to "$(pwd)"

I believe this is just a matter to do a test and using the appropriate method which returns a path checking for "/" somewhere in the pattern returned

Your thoughts?
 
You are correct I am not specifying any directory when I launch the script expecting it will take the current directory.
This is not a valid assumption for Linux (as I learned a while back and included in the Quickstart notes). You should always include the current directory for executing commands if it's not specified in the PATH environment var. When I run without a path I get the following, which is the expected result.

Code:
admin@AC68R-06650:/tmp/mnt/ASUS# nvram-save.sh -v
-sh: nvram-save.sh: not found

With the path....

Code:
admin@AC68R-06650:/tmp/mnt/ASUS# ./nvram-save.sh -v
NVRAM User Save/Restore Utility
Working Directory /tmp/mnt/ASUS
 
 
nvram-save.sh  Version=22
nvram-merlin.ini  Version=22
nvram-excp-merlin.sh  Version=22
nvram-restore.sh  Version=22
jffs-restore.sh  Version=22

One explanation I found....
It used to be common practice to have . in the PATH, but then it was realized that it was a security risk, so it was removed. Imagine . being at start of PATH. Then a local script called ls could intercept calls to ls. If . is put at the end of PATH, then you install package that has a program with conflicting name then this program is run instead of the one you expect. (You may notice that in cmd on ms-windows . is implicitly in the PATH, this could be considered a bug in cmd, as it can not be changed. You may also note that ms-windows has more virus problems.
 
Q: are Time Machine/AFS and iTunes server settings included in R22? Don't see anything that looks like them in script stdout from R21 and saw a post from February saying they weren't there at that time.

Thanks for this great tool!
 
Status
Not open for further replies.

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top