Commit Graph

42 Commits (master)

Author SHA1 Message Date
Dustin 379eca833c fx-marionette: Exit after idle
dustin/basementhud/pipeline/head This commit looks good Details
By default, `systemd-socket-proxyd` keeps running after the remote
disconnects.  This prevents the HUD control from reconnecting if e.g.
Firefox crashes.
2022-12-13 11:55:31 -06:00
Dustin 6fe27732b3 mkrootfs: Install OpenSSL 1.1
`mqttdpms` is linked against OpenSSL 1.1.  Rather than build multiple
copies that link to different versions, it's easier (for now) to just
install the old version of OpenSSL here.
2022-12-13 11:54:35 -06:00
Dustin 8acc69f9ba mkrootfs: Disable pam_sss
Fedora's default PAM configuration assumes SSSD is installed.  Since it
isn't, the system log is littered with errors about it:

> PAM unable to dlopen(/usr/lib64/security/pam_sss.so): /usr/lib64/security/pam_sss.so: cannot open shared object file: No such file or directory
> PAM adding faulty module: /usr/lib64/security/pam_sss.so
2022-12-13 11:53:04 -06:00
Dustin 0caf50f656 xinit: Start Xorg on tty1
Because `tty1` is active when `xinit@user.service` starts on `tty7`,
Xorg cannot bind the modesetting driver to the DRM device:

> (II) systemd-logind: got fd for /dev/dri/card2 226:2 fd 13 paused 1
> (EE) Error systemd-logind returned paused fd for drm node

To fix this, we need to start Xorg on the active console.

Another potential fix would be to run `chvt 7` before running `startx`,
but running the GUI on tty1 seems to be what the major display managers,
e.g. GDM, are doing now.
2022-12-13 11:44:16 -06:00
Dustin 60e03e99fe Update to Fedora 37
dustin/basementhud/pipeline/pr-master This commit looks good Details
dustin/basementhud/pipeline/head This commit looks good Details
2022-12-13 10:01:07 -06:00
Dustin 5a1054bf01 ci: Remove Clean parameter
This parameter no longer makes sense as the workspace is not preserved
between runs anyhow.
2022-12-01 20:40:27 -06:00
Dustin 19cb4256f3 ci: Run in kubernetes
dustin/basementhud/pipeline/head This commit looks good Details
2022-12-01 20:03:33 -06:00
Dustin 03da29b5a6 ci: Update mqttdpms Jenkins project name
dustin/basementhud/pipeline/head This commit looks good Details
I've switched Jenkins to use a Gitea Organization Folder so it can
auto-discover repositories owned by my Gitea user.  This naturally
required the paths of existing projects to change.  Here, we're updating
the path to the *mqttdpms* project to reflect its new location.
2022-08-23 09:40:14 -05:00
Dustin 09c7277e30 Run depmod before creating rootfs image
`depmod` needs to be run by `mkrootfs.sh` so that the kernel module
dependency information is included in the SquashFS image.  Without this
information, `modprobe` cannot install kernel modules at runtime.
2022-08-23 09:38:37 -05:00
Dustin ad09bd2cdc Update hudctrl URI
dustin/basementhud/pipeline/head This commit looks good Details
Finally got the HUD controller published somewhere besides my desktop!
2022-08-03 17:09:56 -05:00
Dustin 5083b91871 Install mqttdpms
dustin/basementhud/pipeline/head This commit looks good Details
The `mqttdpms` tool will allow the screens to be turned off and on using
Home Assistant.  We'll install it into the rootfs image by copying the
artifact from its Jenkins build into the overlay tree before building
the image.
2022-08-02 23:04:22 -05:00
Dustin 51a2324a1c xinit: Run openbox-session
basementhud/pipeline/head This commit looks good Details
Running `openbox` does not invoke the autostart script.
2022-05-01 11:10:54 -05:00
Dustin aa6162d37a xinit: Trigger hudctrl after openbox starts
basementhud/pipeline/head This commit looks good Details
The window manager needs to be running before we trigger *hudctrl* to
open the Firefox windows, otherwise they will not be able to go into
fullscreen.
2022-05-01 10:30:06 -05:00
Dustin 01c8c116dd xinit: Trigger hudctrl at boot
basementhud/pipeline/head This commit looks good Details
The *hudctrl* service remotely controls Firefox on the Basement HUD
machine.  It uses Firefox Marionette over TCP, and is itself controlled
by an HTTP API.

When the HUD machine starts up, it sends its monitor configuration to
*hudctrl* and tells it the display is ready to be controlled remotely.

For now, *hudctrl* is hosed on Rosalina.  I will eventually move it to
the new metrics server, once it's built.
2022-05-01 09:22:48 -05:00
Dustin 6373ca3d08 Use xrandr instead of wmctrl
basementhud/pipeline/head This commit looks good Details
It turns out the Firefox marionette protocol can move/resize the Firefox
window, so `wmctrl` is not needed.  We will need `xrandr`, though, to
help identify screen/monitor geometry, which we will send to the
control service so it knows how to position the Firefox windows.
2022-04-06 18:43:30 -05:00
Dustin cd4144293b Fix group owner of overlay files
Need to set the GID owner of all files copied in from the overlay
directory to *root*/`0`, to match the user/UID.
2022-04-06 18:43:16 -05:00
Dustin 878f733025 Set GUI time zone from geolocation
The wonderful *ipapi.co* service can help identify the time zone of a
device based on the geolocation information for its IP address.  We can
use this to set the `TZ` environment variable in the user session, which
Firefox will respect.  This has the effect of showing the correct time
in e.g. Grafana dashboards, without hard-coding the time zone in the
rootfs image.
2022-04-06 18:40:58 -05:00
Dustin c7a21b404d Start Firefox as soon as X starts
basementhud/pipeline/head This commit looks good Details
There's no reason to wait for an incoming Marionette connection to start
Firefox.  Anyway, starting it earlier avoids a bunch of "connection
refused" spam from `systemd-socket-proxyd`.
2022-04-06 17:48:45 -05:00
Dustin 4aadca95a2 Do not wait for NTP sync to start Xorg
Now that the system clock is set from the RTC, the time will be close
enough to correct by the time Xorg starts that there won't be any
certificate issues.  We can shave several seconds off the startup time
now.
2022-04-06 17:47:36 -05:00
Dustin 7e12510413 Enable RTC on the CM4 I/O board
basementhud/pipeline/head This commit looks good Details
Include the kernel modules in the initramfs to set the clock as early as
possible.
2022-04-06 17:35:56 -05:00
Dustin ab4c6671f6 Revert "initramfs: Include systemd-timesyncd module"
Dumb.  It just enables the *systemd-timesyncd.service* in the initramfs,
which starts before the dracut initqueue, so there's no network yet.

This reverts commit 3efdfa9e54.
2022-04-06 17:15:58 -05:00
Dustin 4f49686ff1 Fix dhclient removing the IP address on renew
basementhud/pipeline/head This commit looks good Details
For some reason, `dhclient` fires an *EXPIRE* event every time it renews
the DHCP lease, even if the lease has not expired.  `dhclient-script`
then removes the IP address from the interface, which of course breaks
the connection to the NBD server and blocks all reads from the root
filesystem.  To avoid this strange situation, we need to stop
`dhclient-script` acting on the *EXPIRE* event.  Luckily, it provides a
"hook" mechanism that we can use; since the hook script is dot-sourced,
we can just `exit` the process to avoid any further changes in that run.
2022-04-06 16:46:44 -05:00
Dustin 93c9c90468 Create empty /run/resolv.conf
basementhud/pipeline/head This commit looks good Details
This just avoids an error issued by dhclient:

> dhclient: /etc/resolv.conf is broken symlink. Recreating...
2022-04-06 16:07:37 -05:00
Dustin 3efdfa9e54 initramfs: Include systemd-timesyncd module
basementhud/pipeline/head This commit looks good Details
This should ensure the clock is set correctly before switching to the
real root, which will make log entries a lot easier to read.
2022-04-06 15:05:32 -05:00
Dustin f25226ebb5 Stub out kernel-network-modules dracut module
basementhud/pipeline/head This commit looks good Details
This dumb module includes a ton of useless drivers.  There doesn't seem
to be a way to avoid including it, because it is expressed as a
dependency of the *network* module, and even explicitly omitting the
modules it would include seems to have no effect.
2022-04-06 13:47:32 -05:00
Dustin 3230e6a050 initramfs: Only include necessary drivers
*dracut* includes a ton of kernel modules in the initramfs by default.
These are totally unnecessary and make the image file huge, which makes
it take forever to load via TFTP.  We can save a lot of space and time
by only including the specific drivers we need to mount the root
filesystem.
2022-04-06 13:42:04 -05:00
Dustin 3e2e54d3cc Install wmctrl
basementhud/pipeline/head This commit looks good Details
`wmctrl` is needed to resize/reposition windows, since *openbox* does
not have any native automation capabilities.
2022-04-06 10:57:25 -05:00
Dustin 406c0b869e Allow access to the emergency shell
basementhud/pipeline/head This commit looks good Details
By default, the emergency shell prompts for the root password.  If the
root account is locked, the emergency shell is unusable.  This makes it
impossible to troubleshoot issues before the network is available.
Fortunately, systemd can be configured to skip the root password prompt
and allow access to the emergency shell with an environment variable.
2022-04-06 10:13:52 -05:00
Dustin d22ad7da6e Remove Firefox policy/autoconfig
basementhud/pipeline/head This commit looks good Details
This seems to be interfering with Marionette?
2022-04-05 18:14:26 -05:00
Dustin d6139d4884 Switch from NetworkManager to dhclient
basementhud/pipeline/head This commit looks good Details
NetworkManager is a memory hog.  We don't need it to do anything except
renew the DHCP lease when it's time, so let's switch to a more
lightweight alternative.  Unfortunately, Fedora does not include any
systemd units for `dhclient`, so we have to provide our own.
2022-04-05 17:58:19 -05:00
Dustin 919b578ebc Disable systemd-userdbd/systemd-homed
These are unnecessary and waste memory.
2022-04-05 17:58:19 -05:00
Dustin e055500476 Drop Playwright, run Firefox Marionette
Running Voonex (Python), Playwight (Node.js), and Firefox simultaneously
takes way too much memory.  Using the NBD swap prevents hard lockups and
crashes in OOM situations, but it makes the machine *incredibly* slow.
To avoid needing to push anything into the network swap, I want to try
and reduce the memory footprint as much as possible.  To that end, we
will go back to running just Firefox.  To control it, we will use the
Marionette protocol.

Firefox only allows control via Marionette over the loopback interface.
This is hard-coded in the Marionette server, and cannot be changed at
runtime.  To allow a remote machine (running Voonex) to control it, we
need to expose the socket to the network.  Fortunately, *systemd*
includes a tool for exactly this purpose: `systemd-socket-proxyd`.
2022-04-05 17:58:19 -05:00
Dustin 2a0737ab78 Enable local persistent storage
Machine-specific data, such as SSH keys, should not be included in the
immutable root filesystem image, as this would prevent multiple machines
running from the same image.  These few files can be stored locally, on
the SD card on eMMC flash.

The first time a machine boots up using this image, its local storage is
initialized.  This involves creating a new filesystem on the block
device and generating SSH host keys.  Once the storage is initialized,
it is remounted read-only.  All subsequent mounts are read-only as well.
2022-04-05 14:54:30 -05:00
Dustin 14d0cdcec1 Configure swap space on NBD volume
Using zram to compress pages did not provide enough memory to run
Firefox, Node, and Python for an extended period of time.  Here's hoping
swap-on-NBD will be fast and reliable enough to work.

Note that systemd's default behavior with respect to swap areas is to
enable them all rather early in the boot process, before the network is
fully configured.  As such, we have to use the *noauto* flag to disable
the default dependencies and add our own in a later target.
2022-04-04 20:59:34 -05:00
Dustin 1e96609ebc Install zram-generator
Try to maximize memory efficiency using using an in-memory block device
with on-the-fly compression as swap space.
2022-04-04 20:59:34 -05:00
Dustin 1737604441 rsyslog: Send logs to Graylog
Ideally, we would use the log server address provided by DHCP, but for
now, we will just hard-code the destination.
2022-04-04 20:59:34 -05:00
Dustin a3c2afc3fa Install Playwright to control Firefox
[Playwright] is a cross-browser automation framework, intended for
automating browser-based GUI application tests.  It also works as a
general remote-control tool for automating basically anything having to
do with a browser.

Playwright requires a special Firefox binary that it manages itself.  To
avoid downloading and installing Playwright and Firefox, and thus
storing them in memory, we need them to be already available in the
rootfs image.  Since I want the control software to be updated easily,
without rebooting the machine, I decided to separate it into its own
project, [Voonex].  A short shell script to install/update and run it is
launched by the systemd user instance.

[Playwright]: https://playwright.dev/
[Voonex]: https://git.pyrocufflink.blue/dustin/voonex
2022-04-04 20:59:34 -05:00
Dustin 4ec3117b3c cmdline: enable serial console
While developing, it will be nice to have the serial console available
for troubleshooting, especially for issues that prevent network/SSH from
working correctly.  I've temporarily connected a USB-TTL console cable
to *serial0* to control the serial console of the HUD machine.
2022-04-04 20:59:34 -05:00
Dustin 5c19a75603 publish: Upload rootfs image atomically
Using `--no-W` (disable whole file transfer) saves some time and
bandwidth when uploading the root filesystem image, but it has the
negative side-effect of overwriting the destination file in place.  If
any NBD clients are currently running using the image as their root
filesystem, they are likely to experience SquashFS corruption errors, as
the filesystem driver does not expect the underlying data to change once
it has been mounted.  As such, we have to use the default file transfer
method to create a new file and atomically replace the old file once the
transfer is complete.  The original file will be unlinked and will
eventually be deleted once no clients are using it.
2022-04-04 20:59:34 -05:00
Dustin 95019d20d7 config: disable HDMI overscan
I don't even know why HDMI overscan exists, and I especially don't
understand why it is ON BY DEFAULT on a Raspberry Pi.
2022-04-04 20:59:34 -05:00
Dustin 37ef563b5d Switch to Openbox
Matchbox Window Manager, being designed for mobile devices, does not
handle multiple monitors well.  It manages the monitors together as one
giant screen, which will make it extremely difficult to manage separate
Firefox windows on each screen.  Openbox is almost as lightweight as
Matchbox, but it works significantly better for this use case.
2022-04-04 20:59:34 -05:00
Dustin 2437e6e467 Initial commit 2022-04-04 20:59:32 -05:00