Commit Graph

6 Commits (40bf772034a2b0fc39c094e7edde3f6c8aa430a9)

Author SHA1 Message Date
Dustin 670c1f7561 yellow: Install/configure nginx
We're going to use *nginx* as the reverse proxy in front of Home
Assistant, as well as the web consoles for Zigbee2MQTT and ZWaveJS2MQTT.
It will provide TLS termination for all of these applications.

Since *nginx* will not start without a certificate and private key file
for HTTPS, the *gen-nginx-cert.service* systemd unit generates a
self-signed certificate if one does not already exist.  This ensures
that *nginx* can start by default, but still allows the administrator to
replace the certificate with a trusted one later.

The *nginx* container image has symlinks at `/var/log/nginx/error.log`
and `/var/log/nginx/access.log`, pointing to `/dev/stderr` and
`/dev/stdout`, respectively.  The intent here is to send all log
messages to the container runtime.  Unfortunately, when the the
container is managed by Podman from a systemd unit, the standard output
and standard error streams are connected to the systemd journal via a
UNIX socket.  As a result, the `/dev/stdout` and `/dev/stderr`
pseudo-files cannot be "opened" like normal files or pipes.  Thus, to
forward nginx's logs to the systemd journal correctly, we have to do a
bit of trickery.  For the error log at least, setting `error_log stderr`
works well; nginx simply writes messages to the existing file
descriptor.  Unfortunately, the access log has no such mechanism.  For
that, we use nginx's syslog capabilities.  The `/dev/log` socket is
bind-mounted into the container, and nginx is configured to connect to
it.
2023-03-30 09:23:47 -05:00
Dustin d1db08966d Define Podman zigbee2mqtt/zwavejs2mqtt containers 2023-03-30 09:03:45 -05:00
Dustin 4a2d63c8db yellow: Install BURP
We'll use BURP for backups, just like the old Home Assistant server.

Note that Portage cannot correctly set the ownership of files when
installing to an alternate $ROOT.  To work around this, we replace the
`fowners` function for the *app-backup/burp* ebuild with a no-op, and
then set the permissions of the relevant files using SquashFS
pseudo-file definitions.  Relatedly, we're omitting the files and
directories used by the server-side of BURP.
2023-03-30 09:03:45 -05:00
Dustin b7f2d22586 Configure Mosquitto Podman container 2023-03-30 09:03:45 -05:00
Dustin b1afb4adf1 Configure Home Assistant Podman container
The default Home Assistant configuration does not allow running a
reverse proxy in front of the application.  To enable this, the
`use_x_forwarded_for` and `trusted_proxies` options have to be set.

Since we want `/var/lib/homeassistant` to be a Btrfs subvolume, we can't
simply include the necessary files in the correct location in the rootfs
image.  Instead, we must define "copy tree" (`C`) actions for
`systemd-tmpfiles` to copy them from `/usr/share/factory`.
Unfortunately, `systemd-tmpfiles` considers `v` and `C` actions
conflicting, and thus will not copy the directory contents recursively.
Each file has to be listed explicitly.
2023-03-30 08:56:14 -05:00
Dustin 5328e5482b yellow: Install Podman
Podman will provide the container runtime for Home Assistant et al.
Some additional kernel features are required to run containers.
2023-03-30 08:55:45 -05:00