PHP 8.1.34 being installed still via GUI update. EOL & vulnerable to PHP2Shell?

Very cool @jeremypoulter ! I’d be inclined to agree with @alexandrecuer here - we have two interlinked problems here - one is reliably/atomically serving updates to the deployed fleet of Emon* devices, and the other is efficiently maintaining the operating system itself so we can stay current with the accelerating pace of security updates in this new world of AI cat and mouse games.

I love the architectural approach - an immutable core OS, A/B boot and update stuff - keep the workloads like emoncms and emonhub in containers, makes it very easy to add HA, ebusd, etc etc onto the same hardware, and move away from fragile shell scripts, git pulls and dpkg crunching away and falling over / running out of disk. Endless OS has been doing an immutable OS with ostree since 2014 way before it was cool.:slight_smile:

The RAUC stuff, test harness, etc all looks excellent. If we weren’t on Pi, I’d probably suggest systemd-boot / systemd-sysupdated which is where all of the UAPI / Image Based Linux / systemd / Amutable / etc cool cats are investing. But as we’re on Pi, the “when in Rome…” argument carries a lot of water, and EFI firmware on Pi is really janky.

That said, on the other problem of efficiently maintaining the OS so we can stay current with security updates, moving to effectively committing the OEM project to maintaining their own OS seems like a step in very much the wrong direction. Maintaining our own Buildroot makes every glibc, libpng, etc etc CVE our own responsibility. I know I’m hardly a seasoned contributor here, but I would go far as strongly advising against it. :sweat_smile:

Back to the “when in Rome” argument, given that Raspberry Pi maintain the OS for Raspberry Pi, and Debian maintains the rest, and on the whole we seem to be a Debian shop (I’d assume that our container images will either be Debian based, or Alpine which is kind of just diet Debian for containers), my recommendation would be to keep all of the updater work and infrastructure, and work on a mkosi process to build the OS payloads by unpacking debs. Then we’ll get all of the security updates, latest Pi kernels and firmware, etc for free, and we just have to re-run the image build to get latest everything, rather than keeping on top of dozens of components patches/releases, and hosting multi-TB multi-hour rebuilds. That’s a great deal of human and infrastructure cost for benefits I’d struggle to articulate.

(I’ve not reviewed the code or tried anything yet, but GitHub - valtzu/rpi-mkosi: An example on how to build & distribute images for Raspberry Pi with mkosi · GitHub looks interesting - it goes down the systemd-boot path which I think is overkill, but it might be interesting to look at how they use mkosi.)

Of course, feel free to ignore me - I might be able to find time to play with some of this, but am meant to be reviewing some legal paperwork for work so I can’t promise anything! I’m not the one doing the work and volunteer time is famously non-fungible. Appreciate everything you all do! :heart:

From my point of view mosquitto-PHP is fine

of course it is not really maintained, and it has to be compiled but it does the job. when building the all in one docker alpine image using s6 overlay, I rarely have problem with mosquitto-PHP…

see GitHub - Open-Building-Management/emoncms: emoncms home-assistant addon · GitHub

I haven’t yet, I basically took the original Docker image and updated it with some of the stuff in the all-in-one docker, in principle it can be a base to build on. You actually probably don’t want just one docker image, but one location not get the images. For example my (original) use case was for heatpumpmonitor.org development where I just wanted EmonCMS and not the other stuff. I would imagine the Home Assistant addon includes some bits but not MQTT. This sort of thing is super easy to do as well as things like building different base OSs and you will see many examples of this.

That is the plan, will be transferred to the OEM or EmonCMS org when it is more complete product

You are correct the solid update is only part of the solution, my intention is to use dependabot or a similar tool (Renovate looks promising) to make sure the dependencies are kept up-to-date. This is largely why a added the x86 VM and testing. Depedancies can be updated on a branch, tested and merged automatically. Should even be able to test on a Pi via CI, we found this great product, USB-SD-Mux, that allows you to pragmatically switch an SD card between a PC and the Pi.

I will certainly take a look at mkosi, but the use of build root (which is what Alpine is based on, not Debian) vastly reduces the dependencies so there are only a handful, The kernel, build root, docker, RAUC and maybe a few others, once you have had to deal with Node depedancies that is child’s play :wink: The build time is a currently around 1-3 hours on the default GitHub runners (depending on caching) though which is not great so definitely something I want to look at.

beyond my limted knowledge, but the other use case is running emoncms on a PVE setup. Previously I have used the build scripts on an Ubuntu Container. PVE is definitely a use case to be considered :slight_smile:

Thanks @jeremypoulter, I didn’t mean to suggest Alpine was derived from Debian, it was just me being glib. :slight_smile: Fundamentally for me, it’s an OS that someone else maintains, and we can consume their binaries and pull in the packages we need.

I totally agree that automating maintenance and testing as much as possible is the goal - Renovate, QEMU and USB-SD-Mux testing are all very cool, and a Dockerfile can get us a consistent build environment. But I don’t think either of those necessarily tracks through to “so we should use Buildroot”.

For Raspberry Pi, their serving suggestion is Raspberry Pi OS, and that’s the system they support first with kernels, firmware, etc. If we build on that, backed by Debian’s security team, our security updates and hardware support are as current as Raspberry Pi OS itself, or at worst one rebuild / re-pin away, which is the work of minutes rather than hours.

Rather than argue in the abstract, my friend Claude and I tried mocking it up for the x86 target: EmonOS without Buildroot: building its A/B images and RAUC bundle from Debian packages with mkosi (proof of concept) · GitHub. It’s a Debian builder Dockerfile, a ~40-line mkosi.conf and a build script. It runs against your EmonOS checkout and re-uses the overlays, prepare-target.sh, slot layout, genimage config, GRUB A/B script and bundle.sh more or less unchanged. It looks promising to me:

  • A clean build takes about 50 seconds. The system slot is 306 MB.
  • It boots your A/B layout in QEMU, and RAUC, Docker, first-boot, persist and so on all come up.
  • rauc install of the Debian-built bundle → reboot → boots slot B.

Caveats are in the README. The Pi is untested, U-Boot would still need building from source for your env layout, Debian stable has RAUC 1.13 and Docker 26 rather than the latest (we could add Docker’s own apt repo), and I haven’t ported the data-image preload so it just does boot testing rather than your full test suite.

(I’d also look at whether we can avoid U-Boot entirely and use the Pi firmware’s tryboot A/B support, which already works on Pi 4 and Pi 5 and is what Raspberry Pi themselves have signed up to support going forward. It would mean each slot’s kernel lives on its own FAT boot partition, so the partition layout would change a bit. Pi 5 support has also taken a long time to land upstream in U-Boot.)

Not a merge request, just a sketch of something that to me has fewer moving parts and doesn’t need us to take on any Buildroot building/maintenance/etc, but still gets all of the atomic A/B updates and automated testing, which to me is the hugely valuable piece. Would love to know what you think if you have a chance to play with it.

So to some degree the starting point of the project was HAOS and that is the structure they took, so it is not like we would be winging it, but equally a do see (and agree with) your points. Will definitely take a look at what you have done. If it doesn’t make things to complicated I may try building both solutions in parallel.

In principle already done, there is an x86 VM version. Not tried it in Proxmox directly but no reason it should not work. I do however wonder if an ISO would be easier so you can do it from the GUI, for some reason Proxmox does not support importing images from the GUI, at least it didn’t last time I tried it.

There is MQTT on the HA addon but you can use external broker if yu want

While we continue working on the longer term plan here I’ve released an interim emonSD image build using our existing build script process but now with a new fully automated end-to-end build process, thanks to claude for the implementation and @jeremypoulter for the inspiration!

The image now builds locally on Ubuntu using systemd-container qemu-user-binfmt and passt. It includes your tip @ramcq on removing the Pi camera packages and your log2ram fix:

https://community.openenergymonitor.org/t/new-emonsd-release-emonsd-10nov26-raspberry-pi-os-trixie/30650

Cool. I’ll see if I can cook a draft PR which adds a mkosi option to your repo. It actually comes out smaller/cleaner than my proof of concept because we can have mkosi do more of the image cookery, so more of the config is declarative rather than scripts. Some points for discussion/consideration - would it be worth prototyping a (Pi-specific) try boot bootloader integration with RAUC so we can skip uboot? And there’s even a Grub-free option - subject to properly working EFI firmware - where we use RAUC’s EFI integration to do BootNext. If we want to support running on broken PC firmware this isn’t a good plan, but if the x86 image is just for VMs maybe it’s worth considering. Less sold on that than eliminating the uboot moving part though.

That would be great, I am cooking up a plan to get to an initial release version, and doing a PoC around Debian would be part of that. I would like to run both in parallel at least initially. I am about 70% convinsed that it is the correct direction but want to get the dependancy managment peice also in place before selecting one over the other.

That’s great news, Trystan - thanks for all your hard work with this.

I’m a tiny bit confused though, as to the correct direction to follow.

Can I just use the inbuilt Update process to take my existing (recently-updated) emonpiRelease: emonSD-01Feb24, up to a level where all these changes are included automatically?

Or do I have to (somehow) start over on an entirely fresh SD card with this new emonSD releate and import the datasets from the old one? I recall doing that a year or so ago and it was minorly nailbiting but I managed it eventually (my install has a homebrew script which runs my own meter LED pulse-reading circuit, so I have to remember to copy all that across and get it working too, which complicates matters a bit).

Obviously the ‘GUI update’ method is by far the simplest if it works, but if it’s no longer going to cut it for this release-jump, so be it. I’ll have to get the coffee-pot on… :wink:

Thanks again!

One other thought I had, do we think there is value in an emonhub only version? My thinking is for larger instilations you could have many emonhub nodes, maybe even running on a Pi Zero, and sending data to a central EmonCMS. Probably wouldn’t be in an initial release, but if it would be useful will dictate if emonhub lives as its own container or not.

Unfortunately for the emonSD-10Nov26 release it’s not something that can be updated from the UI, it does require flashing the new image to a new SD card and then the way I recommend updating is to put the old SD card in a USB SD card reader and plug that into your emonPi and then use the import from external USB reader tool available in the backup module.

The full OS and dependencies update from the UI, without having to do the whole multiple SD card and import process that’s currently needed, is what @jeremypoulter is working to fix :slight_smile:

This does make sense, i think the main issue with this at the moment is that we dont have a minimal UI for WiFi configuration that is separate from Emoncms. Perhaps minimal emonhub image with a dedicated mini UI could work?

This reads as if it precludes backing up the data to a file on another machine, flashing a new SD card (or reflashing the old) with the new image and then restoring the backup. Is this correct or is the backup and restore path still viable?

Perhaps minimal emonhub image with a dedicated mini UI could work?

Don’t see why not, and can work with that in mind if that is a desirable usecase