Further updates to and hardening of api2install.sh

Thanks to www.shellcheck.net, an excellent script checking tool\!