What's new

Scribe General: would a few people verify firmware binary locations?

  • 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!

cmkelley

Very Senior Member
We recently discovered that not every router has the "nvram" binary in the same location. Mine (AC86U) is in /bin. Apparently at least in the AC68U, nvram is in /usr/sbin.

When writing scribe, to prevent other installed entware programs from interfering, I tried to explicitly call most binaries (e.g. /bin/grep, /usr/bin/awk, etc.). No good deed going unpunished, that resulted in scribe refusing to install on AC68U due to nvram not being where I thought it was. SO, I got to wondering, I wonder if ASUS has moved other firmware binaries around that I am expecting to be where they happen to be on the AC86U.

I have an AC68U that I use for a mesh node (so I don't even install Merlin on it), and found nothing else had moved. So there's hope this is not necessary, but I'd like to check.

If I could get a few people to run the below on their routers, and let me know the model, and if any of the firmware binaries come up "MOVED". Hopefully they all say "okay". I don't need the whole list, just your router model and the ones (if any) that moved.

Code:
#!/bin/sh -

[ -e /bin/cat ] && echo "cat okay" || echo "cat MOVED"
[ -e /bin/chmod ] && echo "chmod okay" || echo "chmod MOVED"
[ -e /bin/cp ] && echo "cp okay" || echo "cp MOVED"
[ -e /bin/grep ] && echo "grep okay" || echo "grep MOVED"
[ -e /bin/ln ] && echo "ln okay" || echo "ln MOVED"
[ -e /bin/ls ] && echo "ls okay" || echo "ls MOVED"
[ -e /bin/mkdir ] && echo "mkdir okay" || echo "mkdir MOVED"
[ -e /bin/mv ] && echo "mv okay" || echo "mv MOVED"
[ -e /bin/pidof ] && echo "pidof okay" || echo "pidof MOVED"
[ -e /bin/ps ] && echo "ps okay" || echo "ps MOVED"
[ -e /bin/rm ] && echo "rm okay" || echo "rm MOVED"
[ -e /bin/sed ] && echo "sed okay" || echo "sed MOVED"
[ -e /bin/tar ] && echo "tar okay" || echo "tar MOVED"
[ -e /bin/touch ] && echo "touch okay" || echo "touch MOVED"
[ -e /bin/uname ] && echo "uname okay" || echo "uname MOVED"
[ -e /sbin/syslogd ] && echo "syslogd okay" || echo "syslogd MOVED"
[ -e /usr/bin/awk ] && echo "awk okay" || echo "awk MOVED"
[ -e /usr/bin/basename ] && echo "basename okay" || echo "basenamne MOVED"
[ -e /usr/bin/clear ] && echo "clear okay" || echo "clear MOVED"
[ -e /usr/bin/cut ] && echo "cut okay" || echo "cut MOVED"
[ -e /usr/bin/find ] && echo "find okay" || echo "find MOVED"
[ -e /usr/bin/md5sum ] && echo "md5sum okay" || echo "md5sum MOVED"
[ -e /usr/bin/tail ] && echo "tail okay" || echo "tail MOVED"
[ -e /usr/bin/top ] && echo "top okay" || echo "top MOVED"
[ -e /usr/bin/unzip ] && echo "unzip okay" || echo "unzip MOVED"
[ -e /usr/sbin/cru ] && echo "cru okay" || echo "cru MOVED"
[ -e /usr/sbin/curl ] && echo "curl okay" || echo "curl MOVED"
copy to a file, make it executable, etc. You know the drill. :) No rush (unless you're having problems!), just checking.
 
You could use the export PATH in your script which I did for a while in amtm and AB-Solution.
Anyway, because we can, I could not resist to do some mods:
Code:
#!/bin/sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
[ -z "$(nvram get odmpid)" ] && model="$(nvram get productid)" || model="$(nvram get odmpid)"
echo "$model ($(uname -m)), $(uname -o) FW-$(nvram get buildno)"

binaries='
/bin/cat
/bin/chmod
/bin/cp
/bin/grep
/bin/ln
/bin/ls
/bin/mkdir
/bin/mv
/bin/pidof
/bin/ps
/bin/rm
/bin/sed
/bin/tar
/bin/touch
/bin/uname
/sbin/syslogd
/usr/bin/awk
/usr/bin/basename
/usr/bin/clear
/usr/bin/cut
/usr/bin/find
/usr/bin/md5sum
/usr/bin/tail
/usr/bin/top
/usr/bin/unzip
/usr/sbin/cru
/usr/sbin/curl'

for i in $binaries; do
    [ -s "${i}" ] && echo "${i} okay" || echo "${i} MOVED"
done
Edit: Corrected PATH definition, thanks @Martinski

Now for the output:
Code:
RT-AX88U (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay

Code:
RT-AX86S (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay

Code:
RT-AX56U (armv7l), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Last edited:
Code:
RT-AC1900P (armv7l), ASUSWRT-Merlin FW-386.7
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Code:
RT-AC66U (mips), ASUSWRT-Merlin-LTS FW-374.43
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
Code:
RT-AC66U (mips), ASUSWRT-Merlin FW-380.70
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Just a small correction:
Bash:
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
I remember this was pointed out to me years ago and then changed it. I just copied it from a very old AB-Solution version ;)
Thanks!
 
Nothing moved on a RT-AX86U Pro running 388.2:
Code:
cat okay
chmod okay
cp okay
grep okay
ln okay
ls okay
mkdir okay
mv okay
pidof okay
ps okay
rm okay
sed okay
tar okay
touch okay
uname okay
syslogd okay
awk okay
basename okay
clear okay
cut okay
find okay
md5sum okay
tail okay
top okay
unzip okay
cru okay
curl okay
Edit to add: LonelyCoder's script output because why not. :)
Code:
RT-AX86U_Pro (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
nvram in /bin
Code:
RT-AX88U (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Code:
GT-AX6000 (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
AX88U Pro running 388.2

cat okay
chmod okay
cp okay
grep okay
ln okay
ls okay
mkdir okay
mv okay
pidof okay
ps okay
rm okay
sed okay
tar okay
touch okay
uname okay
syslogd okay
awk okay
basename okay
clear okay
cut okay
find okay
md5sum okay
tail okay
top okay
unzip okay
cru okay
curl okay
 
You could use the export PATH in your script which I did for a while in amtm and AB-Solution.
Anyway, because we can, I could not resist to do some mods:
Code:
#!/bin/sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
[ -z "$(nvram get odmpid)" ] && model="$(nvram get productid)" || model="$(nvram get odmpid)"
echo "$model ($(uname -m)), $(uname -o) FW-$(nvram get buildno)"

binaries='
/bin/cat
/bin/chmod
/bin/cp
/bin/grep
/bin/ln
/bin/ls
/bin/mkdir
/bin/mv
/bin/pidof
/bin/ps
/bin/rm
/bin/sed
/bin/tar
/bin/touch
/bin/uname
/sbin/syslogd
/usr/bin/awk
/usr/bin/basename
/usr/bin/clear
/usr/bin/cut
/usr/bin/find
/usr/bin/md5sum
/usr/bin/tail
/usr/bin/top
/usr/bin/unzip
/usr/sbin/cru
/usr/sbin/curl'

for i in $binaries; do
    [ -s "${i}" ] && echo "${i} okay" || echo "${i} MOVED"
done
Edit: Corrected PATH definition, thanks @Martinski

Now for the output:
Code:
RT-AX88U (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay

Code:
RT-AX86S (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay

Code:
RT-AX56U (armv7l), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
Ahhhh, I thought about that but then I was confused (at it was late so I didn't run a simple test) about the effects of export. I thought because exports in .profile were "permanent" then exports in any script would affect the user after the program ended. But a simple test script proved that to be false, so clearly I don't understand how .profile is sourced. This will actually allow a couple changes to scribe I'd thought about making.

Even though it looks like nvram was the only thing that got moved, I'm wondering if I should go to your original method to be safe, since Asus seems to occasionally move stuff from model to model. Hrmmmmmmmmmm.

Of course, if it wasn't for late at night, I wouldn't get any work on scribe done outside of the weekends ... so everyone else gets to pay the price for this not being my day job. LOL.
 
Ahhhh, I thought about that but then I was confused (at it was late so I didn't run a simple test) about the effects of export. I thought because exports in .profile were "permanent" then exports in any script would affect the user after the program ended. But a simple test script proved that to be false, so clearly I don't understand how .profile is sourced. This will actually allow a couple changes to scribe I'd thought about making.

Even though it looks like nvram was the only thing that got moved, I'm wondering if I should go to your original method to be safe, since Asus seems to occasionally move stuff from model to model. Hrmmmmmmmmmm.

Of course, if it wasn't for late at night, I wouldn't get any work on scribe done outside of the weekends ... so everyone else gets to pay the price for this not being my day job. LOL.
The export PATH if added to the script only affects the script afaik. Hence I removed it from amtm as it would affect third party scripts when started through amtm.
 
The export PATH if added to the script only affects the script afaik. Hence I removed it from amtm as it would affect third party scripts when started through amtm.
Okay, that makes more sense then, it only affects the script it's in and any scripts / programs called by that script. But once the original script terminates, it reverts to how it was before. So downstream only, not upstream.

OH! Just dawned on me then that's why .profile is persistent, it's called by the current environment when the shell started - it's not executed, it's sourced. I blame not thinking about this stuff for 3 otherwise very stressful years. :p
 
Code:

GT-AX6000 (aarch64), ASUSWRT-Merlin FW-388.2
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Code:
RT-AC68U (armv7l), ASUSWRT-Merlin FW-386.11
/bin/cat okay
/bin/chmod okay
/bin/cp okay
/bin/grep okay
/bin/ln okay
/bin/ls okay
/bin/mkdir okay
/bin/mv okay
/bin/pidof okay
/bin/ps okay
/bin/rm okay
/bin/sed okay
/bin/tar okay
/bin/touch okay
/bin/uname okay
/sbin/syslogd okay
/usr/bin/awk okay
/usr/bin/basename okay
/usr/bin/clear okay
/usr/bin/cut okay
/usr/bin/find okay
/usr/bin/md5sum okay
/usr/bin/tail okay
/usr/bin/top okay
/usr/bin/unzip okay
/usr/sbin/cru okay
/usr/sbin/curl okay
 
Okay, that makes more sense then, it only affects the script it's in and any scripts / programs called by that script. But once the original script terminates, it reverts to how it was before. So downstream only, not upstream.

OH! Just dawned on me then that's why .profile is persistent, it's called by the current environment when the shell started - it's not executed, it's sourced. I blame not thinking about this stuff for 3 otherwise very stressful years. :p
I just double checked. Adding the export PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH just below the shebang in a script will only affect the script itself, not even the shell your logged into.
So, it's safe for you to ditch the path and only use the binaries name for all your operations as long as you add the export PATH definition. That makes it future proof for you.
If you still want to use an Entware binary instead of the routers built in version, simply use the path to the /opt/ binary.

And I troubleshooted a bug in amtm today for hours, got deeper into the code, tried many things and became angrier the longer it took.
I had no luck.
Then during dinner a thought crossed my mind. I reverted all code back to original and changed one single thing - and the bug was no more.
It was a beautiful sunny Saturday afternoon here in central Switzerland.
 
I see several posts for the same model & firmware version combi.

Does that still add any value?
 
I see several posts for the same model & firmware version combi.

Does that still add any value?
I believe @cmkelley has all the data and hints it needed to fix the mental blockade ;)
 
Similar threads

Similar threads

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