clearfog: Store the machine-id in uboot's env
It would be nice to simply save this into /etc/machine-id, but our
overlayfs which is mounted at /etc makes this, er, "tricky" (just take a
look at the etc-overlay.service). We *could* probably do something like
temporarily mounting the rootfs r/w just to update that file at bootup,
and writing it to the other slot during updates from within RAUC, but
that would be yet another special case. How would we handle the initial
flashing, for example?
This approach, while needlessly complicating the bootloader's setup (and
that's a big consideration for me) makes the overlay FS provisioning a
bit easier. We caught that special case of /etc/machine-id being a mount
of tmpfs early enough. The root filesystem remains truly read-only, etc.
Change-Id: I27972ef99b8e19cd44736d062cb5e6e7a1f16bde
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/system/multi-user.target.wants/save-machineid-to-uboot.service b/board/czechlight/clearfog/overlay/usr/lib/systemd/system/multi-user.target.wants/save-machineid-to-uboot.service
new file mode 120000
index 0000000..b60a4f9
--- /dev/null
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/system/multi-user.target.wants/save-machineid-to-uboot.service
@@ -0,0 +1 @@
+../save-machineid-to-uboot.service
\ No newline at end of file
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/system/save-machineid-to-uboot.service b/board/czechlight/clearfog/overlay/usr/lib/systemd/system/save-machineid-to-uboot.service
new file mode 100644
index 0000000..892411b
--- /dev/null
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/system/save-machineid-to-uboot.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Save the machine-id into U-Boot environment if not set
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c 'fw_printenv machineid &>/dev/null || fw_setenv machineid $(cat /etc/machine-id)'