Cannot downgrade to older firmware version

I tried to downgrade to the v3 firmware following the recommended posts.

I edited out the lines in the updateFirmwareFromFile.sh script as recommended here:

But I get this error:

Do you know what I am doing wrong?

hmm that’s strange, it doesn’t recognise the “sh” interpreter. Try manually adding “sh” to the start of the command and report back. So use the following command:

sh /usr/local/sbin/updateFirmwareFromFile.sh /shares/Public/sq-030401-230-20140415.deb

joskevermeulen wrote:

hmm that’s strange, it doesn’t recognise the “sh” interpreter. 

Sort of, yes, but actually it looks like the updateFirmwareFromFile.sh file has been manipulated on a DOS-like machine.

It has a telltale ^M in that error

/bin/bash^M: Bad interpreter

DOS (and Windows) uses a combination of Carriage Return (^M) plus Line Feed (^J) to end each line;  *nix uses only the Line Feed (^J) which means it might be seeing that unneeded carriage return as part of the interpreter name itself (bash^M).

1 Like

Oh I totally missed the “^M”…

But doesn’t that mean the unneeded carriage return is probably part of the first (shebang) line? And doesn’t my method, of adding “sh” in front of the command, ignores the shebang line?

The first time around, I did indeed edit the file with wordpad, and it failed with the same error. Upon rebooting the NAS though, the changes in the file were erased (the NAS seemed to have restored a proper file version as it was “initializing” upon reboot).

This last time, I used nano in putty to edit the file and add back the # to comment out the lines. Same error through.

I will try joskevermeulen suggestion this evening.

joskevermeulen wrote:

Oh I totally missed the “^M”…

 

But doesn’t that mean the unneeded carriage return is probably part of the first (shebang) line? And doesn’t my method, of adding “sh” in front of the command, ignores the shebang line? 

Yep, that’d do it, but since the shebang uses Bash (not SH) it probably would be safer to invoke it via bash instead of sh.  

But if the ^M is there on the first line, it’s probably on ALL lines which could create more problems regardless of how the script is invoked.

You guys are right, there were plenty of ^M at the end of the lines. I was able to edit them away by search and replace, but the file is still corrupted and fail somewhere else.

I tried to do a system only factory restore, but it doesn’t bring the file back to the original version.

Do you know how I could get the original file back?

Etupes wrote:

 

Do you know how I could get the original file back?

You could download the .deb file and manually unpack it.  Everything will be there.

Or, if worst comes to worst, just re-install the firmware.

I was able to get to the .img file, but I cannot unpack this file. Both 7-zip and UniversalExtractor throw up on that file. I guess my only options are either to wait for the next update, or do a factory restore and reload all content.

Gee, I wish I didn’t rush and kept a copy of the original file. Stupid of me.

Etupes wrote:

I was able to get to the .img file, but I cannot unpack this file.

Right; the img file is actually a disk image for the rootfs partition.

You can “mount” it from almost any linux box.

tony@mars Tue Jul 22 09:33 AM
/home/tony/Downloads/CacheVolume/upgrade> sudo mount rootfs.img test -o loop
tony@mars Tue Jul 22 09:33 AM
/home/tony/Downloads/CacheVolume/upgrade> cd test
tony@mars Tue Jul 22 09:33 AM
/home/tony/Downloads/CacheVolume/upgrade/test> ls
bin boot dev etc home lib lost+found media mnt opt proc root run sbin selinux srv sys tmp usr var
tony@mars Tue Jul 22 09:33 AM
/home/tony/Downloads/CacheVolume/upgrade/test> ls -la usr/local/sbin/updateFirmwareFromFile.sh
-rwxr-xr-x 1 root root 8289 Jun 21 2013 usr/local/sbin/updateFirmwareFromFile.sh
tony@mars Tue Jul 22 09:33 AM
/home/tony/Downloads/CacheVolume/upgrade/test>

If you don’t have a linux box, you can do it from almost any “live” distro, or just run one within a virtualbox.

OK. Thank you. I will stick with this firmware for the time being. Installing a Linux distro is too involved to solve for this problem.

TonyPh12345 wrote:

Yep, that’d do it, but since the shebang uses Bash (not SH) it probably would be safer to invoke it via bash instead of sh.  

 

But if the ^M is there on the first line, it’s probably on ALL lines which could create more problems regardless of how the script is invoked.

 

Good point. I know I’ve used commands in the past to “clean” files from windows style formatting, but I can’t remember…

/bin/sh is symlinked to /bin/bash so it doesn’t matter which is used.

On how to remove the ^M if anybody ends up editing a file using wordpad or equivalent on Windows

.

http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/