Earlier this evening I tried to run your script but immediately got 2 errors about "
parameter not set" for
RED and then
NOCOLOR vars, so I ended up deleting those variables from the script. Then I ran it again and the script got stuck in an infinite loop so I had to kill the "
nvramcheck.sh" process every time (regardless of whether I answer Y or N to the initial question). I briefly debugged it and found that your script assumes that every single "
nvram get ..." call will return a non-NULL/non-empty result, but this is an incorrect assumption.
In practice, sometimes there are calls to NVRAM vars that are not set all, or to NVRAM vars that are set to an empty string. In each instance, the "
nvram get ..." call must be handled appropriately, but your current script ends up in an infinite loop in all such cases.
There are also some strange (to me) syntax forms, and I don't understand their purpose. I'm not talking about differences in coding styles, but about some syntactic statements that within their particular context appear to be completely unnecessary, IMO.
For example:
Bash:
case $yn in
[Yy]* ) CHECKNVRAM="1" && break;;
[Nn]* ) CHECKNVRAM="0" && break;;
* ) echo -e "${RED}Invalid Selection!!! ***Enter Y for Yes or N for No***${NOCOLOR}"
esac
I don't see the purpose of the two "
&& break" expressions above, especially since the entire case statement is *not* found within the scope of any type of
loop statement (e.g. while, until, for, etc.). Yes, those "break" cmds don't "hurt or break anything" but seem superfluous in the above context.
There are other examples of "strange" syntactic forms, but I don't want to minimize your efforts or appear to be simply criticizing your work. Perhaps there is indeed a purpose to those strange statements that I'm not aware of.
In any case, the current version of your script just doesn't run successfully on my RT-AC86U router, so your solution is not quite there yet, IMO.
My 2 cents.