From 4367b56120f0103853d67ab493ba0ecfc94cb2ab Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Mon, 24 Mar 2025 17:29:24 -0600 Subject: [PATCH] Restore some default behaviors - If `init` is not specified, wwinit looks for /sbin/init, /etc/init, and /bin/init, matching dracut behavior. - assume ipxe template=default if not set - Display a warning during overlay build if an overlay list is empty Issues: - Closes: #1808 - Closes: #1813 Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 3 +++ internal/pkg/overlay/overlay.go | 6 +++++ internal/pkg/warewulfd/provision.go | 6 ++++- overlays/wwinit/rootfs/warewulf/wwprescripts | 28 +++++++++++++++++--- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6678b455..d1a1483a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fixed display of dotted field names. #1825 - Add single quote around escapechar in ipmitool template #1830 - Update nodes and profiles when renaming an image. #1637 +- If init is not specified, wwinit looks for /sbin/init, /etc/init, and /bin/init. #1808 +- assume ipxe template=default if not set. #1808, #1813 +- Display a warning during overlay build if an overlay list is empty. #1808 ### Changed diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 3b76ae4f..4b9d80d1 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -110,12 +110,18 @@ func BuildAllOverlays(nodes []node.Node, allNodes []node.Node, workerCount int) for n := range nodeChan { wwlog.Info("Building system overlay image for %s", n.Id()) wwlog.Debug("System overlays for %s: [%s]", n.Id(), strings.Join(n.SystemOverlay, ", ")) + if len(n.SystemOverlay) < 1 { + wwlog.Warn("No system overlays defined for %s", n.Id()) + } if err := BuildOverlay(n, allNodes, "system", n.SystemOverlay); err != nil { errChan <- fmt.Errorf("could not build system overlays %v for node %s: %w", n.SystemOverlay, n.Id(), err) } wwlog.Info("Building runtime overlay image for %s", n.Id()) wwlog.Debug("Runtime overlays for %s: [%s]", n.Id(), strings.Join(n.RuntimeOverlay, ", ")) + if len(n.RuntimeOverlay) < 1 { + wwlog.Warn("No runtime overlays defined for %s", n.Id()) + } if err := BuildOverlay(n, allNodes, "runtime", n.RuntimeOverlay); err != nil { errChan <- fmt.Errorf("could not build runtime overlays %v for node %s: %w", n.RuntimeOverlay, n.Id(), err) } diff --git a/internal/pkg/warewulfd/provision.go b/internal/pkg/warewulfd/provision.go index 07e261dd..83608d0e 100644 --- a/internal/pkg/warewulfd/provision.go +++ b/internal/pkg/warewulfd/provision.go @@ -97,7 +97,11 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) { } } else if rinfo.stage == "ipxe" { - stage_file = path.Join(conf.Paths.Sysconfdir, "warewulf/ipxe/"+remoteNode.Ipxe+".ipxe") + template := remoteNode.Ipxe + if template == "" { + template = "default" + } + stage_file = path.Join(conf.Paths.Sysconfdir, "warewulf/ipxe", template+".ipxe") kernelArgs := "" kernelVersion := "" if remoteNode.Kernel != nil { diff --git a/overlays/wwinit/rootfs/warewulf/wwprescripts b/overlays/wwinit/rootfs/warewulf/wwprescripts index 92342b3a..ce472025 100755 --- a/overlays/wwinit/rootfs/warewulf/wwprescripts +++ b/overlays/wwinit/rootfs/warewulf/wwprescripts @@ -9,6 +9,28 @@ ls -1 "${scriptdir}/" | while read -r name; do echo "Running prescript: ${name}..." sh "${scriptdir}/${name}" done -echo -echo "Running ${WWINIT}..." -exec $WWINIT + +init="${WWINIT}" +if [ -z "${init}" ] +then + for candidate in /sbin/init /etc/init /bin/init + do + if [ -x "${candidate}" ] + then + init="${candidate}" + break + fi + done +fi + +if [ -n "${init}" ] +then + echo + echo "Running ${init}..." + exec "${init}" +else + echo "ERROR: init not defined and not found." + echo "Rebooting in 1 minute..." + sleep 60 + echo b > /proc/sysrq-trigger || /sbin/reboot -f +fi