I would also mention here (apart from the README.md) that the script also works when executed from the namenode.

In fact, maybe it should checked at the begining that the host in which the script is running is the namenode, existing otherwises.