you probably already know this: kms.sh is pretty much the same. Have we considered abstract the helper function somehow?
It's almost all boiler plate now. Plus every three months someone says "we are using an old version of tomcat" followed by a "we shouldn't really be using tomcat" and then nothing happens. As soon as someone actually does the work to get us off of tomcat, this code should hopefully re-arrange into something else that looks more like the rest of Hadoop rather than clearly written as a one-off.
As to the code, I don't really understand why the name var exists, but whatever.