Instead of executing the bootstrap script via ssh,
we now run it once the box boots the first time.
It will update the repo and run the box code, which
needs to contact the appstore in order to get provisioned.
Instead of
appname.username.cloudron.us
we now use
appname-username.cloudron.us
This allows us to get a wildcard certificate for cloudron.us and the
ssl stuff will work.
The motivation for appname-username instead of username-appname is primarily
UI at this point. We can show a suffix easily on the right side of a line edit.
Fixes#49
As this script is part of the box repo, it is actually
not intended to be run from here, but we need to store it
somewhere for now. The idea is to copy it to a pristine
ubuntu droplet, run it and then create a new base image for
cloudrons off of that droplet.
This change makes it clear that we are really after the fqdn and not the hostname.
The code has been working only because Digital Ocean sets the hostname
to be the FQDN.
What I learnt about hostnames
-----------------------------
The kernel has get/sethostname() and get/setdomainname() system calls.
There is restriction on what can be set as the hostname. init scripts
usually set the contents of /etc/hostname. How hostname is setup depends
on the distribution - it could be the simple name OR the fqdn. CentOS
for example puts the FQDN and ubuntu puts the simple name.
DigitalOcean puts the name of the box in /etc/hostname. So far this has
worked in our favor because os.hostname() which uses gethostname() gave
us the FQDN.
Docker sets only the simple name in /etc/hostname but sets up the
OS host/domain name correctly. This mean os.hostname() does not provide
the FQDN in docker. Altering it is not possible because it requires the
the SYS_ADMIN caps which container don't have (unless --priveliged).
Also, hostname -f first does gethostname(), then does a DNS lookup
using getaddrinfo() or the deprecated getaddressbyname(). Using that IP,
it does a reverse lookup.
The DNS system itself using nsswitch.conf to determine look up order.
The first entry in /etc/hosts file is taken as the domain entry for
reverse lookups.