Integrate API into installer script to automatically create device

Script now takes -t and -g options as optional instead of -k so if the
agent key is not specified, an API token can be specified instead. The
script will then call the API and create the new device based on the
hostname (optionally specifying a group too), get the agent key and
populate the config file appropriately.

Thanks to Scott Feinberg <scott@allout.org> for the initial code for
this.