From bc53b0de3acd08434c97c0b75e76013fd845c07b Mon Sep 17 00:00:00 2001 From: Itxaka Date: Thu, 16 Feb 2023 15:30:54 +0100 Subject: [PATCH] Workaround for kairos sdk not detecting netboot Signed-off-by: Itxaka --- Earthfile | 14 +++++++++++++- pkg/mount/dag_steps.go | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 7877899..77b27a8 100644 --- a/Earthfile +++ b/Earthfile @@ -62,7 +62,19 @@ build-immucore: ARG LDFLAGS="-s -w -X github.com/kairos-io/immucore/internal/version.version=$VERSION" RUN echo ${LDFLAGS} RUN CGO_ENABLED=0 go build -o immucore -ldflags "${LDFLAGS}" - SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION + SAVE ARTIFACT /work/immucore immucore AS LOCAL build/immucore-$VERSION + +dracut-artifacts: + FROM $BASE_IMAGE + WORKDIR /build + COPY --dir dracut/28immucore . + COPY dracut/02-kairos-setup-initramfs.conf . + COPY dracut/10-immucore.conf . + COPY dracut/50-kairos-initrd.conf . + SAVE ARTIFACT 28immucore 28immucore + SAVE ARTIFACT 02-kairos-setup-initramfs.conf 02-kairos-setup-initramfs.conf + SAVE ARTIFACT 10-immucore.conf 10-immucore.conf + SAVE ARTIFACT 50-kairos-initrd.conf 50-kairos-initrd.conf build-dracut: FROM $BASE_IMAGE diff --git a/pkg/mount/dag_steps.go b/pkg/mount/dag_steps.go index 9ab26ec..a2e7df8 100644 --- a/pkg/mount/dag_steps.go +++ b/pkg/mount/dag_steps.go @@ -343,6 +343,17 @@ func (s *State) WriteSentinelDagStep(g *herd.Graph) error { default: sentinel = string(state.Unknown) } + + // Workaround for runtime not detecting netboot as live_mode + // Needs changes to the kairos sdk + // TODO: drop once the netboot detection change is on the kairos sdk + cmdline, err := os.ReadFile("/proc/cmdline") + cmdlineS := string(cmdline) + if strings.Contains(cmdlineS, "netboot") { + sentinel = "live_mode" + } + + s.Logger.Info().Str("to", sentinel).Msg("Setting sentinel file") err = os.WriteFile(filepath.Join("/run/cos/", sentinel), []byte("1"), os.ModePerm) if err != nil { return err