- Update dracut scripts, iPXE template, and GRUB config templates to use new route paths and TLS-aware logic - Minor troubleshooting doc cleanup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jonathon Anderson <janderson@ciq.com>
102 lines
3.5 KiB
Bash
102 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
[ -z "${wwinit_root_device}" ] && return 0
|
|
|
|
# Resolve the server base URL and hardware address from kernel parameters.
|
|
# Supports two formats:
|
|
# New: wwinit.server=http://host:port (uses wwid kernel param for hwaddr)
|
|
# Legacy: wwinit.uri=http://host:port/provision/hwaddr (extracts hwaddr from path)
|
|
# wwinit.server takes precedence over wwinit.uri when both are present.
|
|
resolve_base() {
|
|
local val="${wwinit_server:-${wwinit_uri}}"
|
|
if echo "${val}" | grep -q '/provision/'; then
|
|
# Legacy: http://host:port/provision/hwaddr
|
|
ww_base="${val%%/provision/*}"
|
|
ww_hwaddr="${val##*/provision/}"
|
|
else
|
|
# New: http://host:port
|
|
ww_base="${val}"
|
|
ww_hwaddr="$(getarg wwid)"
|
|
fi
|
|
}
|
|
|
|
resolve_base
|
|
|
|
get_stage() {
|
|
stage="${1}"
|
|
base="${2:-${ww_base}}"
|
|
cacert="${3}"
|
|
info "warewulf: loading stage: ${stage}"
|
|
# Load runtime overlay from a static privledged port.
|
|
# Others use default settings.
|
|
localport=""
|
|
if [ "${stage}" = "runtime" ]; then
|
|
localport="--local-port 1-1023"
|
|
fi
|
|
cacert_opt=""
|
|
if [ -n "${cacert}" ]; then
|
|
cacert_opt="--cacert ${cacert}"
|
|
fi
|
|
local hwaddr="${ww_hwaddr}"
|
|
case "${stage}" in
|
|
image) uri="${base}/image/${hwaddr}" ;;
|
|
system) uri="${base}/system/${hwaddr}" ;;
|
|
runtime) uri="${base}/runtime/${hwaddr}" ;;
|
|
esac
|
|
(
|
|
curl --location --silent --get ${localport} ${cacert_opt} \
|
|
--retry 60 --retry-connrefused --retry-delay 1 \
|
|
--data-urlencode "assetkey=${wwinit_assetkey}" \
|
|
--data-urlencode "uuid=${wwinit_uuid}" \
|
|
--data-urlencode "compress=gz" \
|
|
"${uri}" \
|
|
| gzip -d \
|
|
| cpio -ium --directory="${NEWROOT}"
|
|
)
|
|
}
|
|
|
|
mkdir /tmp/wwinit
|
|
(
|
|
# fetch the system overlay into /tmp/wwinit
|
|
local NEWROOT=/tmp/wwinit
|
|
get_stage "system" || die "Unable to load stage: system"
|
|
)
|
|
if [ -x /tmp/wwinit/warewulf/run-wwinit.d ]; then
|
|
PREFIX=/tmp/wwinit /tmp/wwinit/warewulf/run-wwinit.d
|
|
fi
|
|
|
|
info "warewulf: mounting ${wwinit_root_device} at ${NEWROOT}"
|
|
(
|
|
if [ "${wwinit_root_device}" = "tmpfs" ]; then
|
|
mount -t tmpfs -o mpol=interleave ${wwinit_tmpfs_size_option} "${wwinit_root_device}" "${NEWROOT}"
|
|
else
|
|
mount "${wwinit_root_device}" "${NEWROOT}"
|
|
fi
|
|
) || die "warewulf: failed to mount ${wwinit_root_device} at ${NEWROOT}"
|
|
|
|
for stage in "image" "system"; do
|
|
get_stage "${stage}" || die "Unable to load stage: ${stage}"
|
|
done
|
|
|
|
# Fetch runtime overlay (non-fatal)
|
|
# Source config from system overlay for TLS settings
|
|
. /tmp/wwinit/warewulf/config
|
|
cert_file="/tmp/wwinit/warewulf/tls/warewulf.crt"
|
|
if [ "${WWTLS}" = "true" ] && [ -f "$cert_file" ]; then
|
|
# TLS enabled: build HTTPS base URL using server address from kernel cmdline
|
|
# (mirrors wwclient URL construction in internal/app/wwclient/root.go)
|
|
tls_base="https://${WWIPADDR}:${WWTLSPORT}"
|
|
get_stage "runtime" "${tls_base}" "${cert_file}" || warn "warewulf: unable to load runtime overlay over HTTPS (ignored)"
|
|
else
|
|
# No TLS: fetch runtime over HTTP
|
|
get_stage "runtime" || warn "warewulf: unable to load runtime overlay (ignored)"
|
|
fi
|
|
|
|
# Copy /warewulf/run from initramfs to NEWROOT
|
|
# This preserves state files created by wwinit.d scripts (e.g., ignition marker)
|
|
if [ -d /tmp/wwinit/warewulf/run ]; then
|
|
info "warewulf: preserving /warewulf/run to mounted root"
|
|
mkdir -p "${NEWROOT}/warewulf"
|
|
cp -a /tmp/wwinit/warewulf/run "${NEWROOT}/warewulf/"
|
|
fi
|