don't rely on HOSTNAME env var

HOSTNAME is a bash-ism, on systemd it will not be set. We can call
socket.getfqdn() ourselves instead, which is equivalent.

Bug: 1106405
Change-Id: I5f5269680c5dac4ab907ad60e6104e944487c118
Merge "don't rely on HOSTNAME env var" into develop