Files
kubesolo-os/init/lib/30-kernel-modules.sh
Adolfo Delorenzo 1de36289a5
Some checks failed
CI / Go Tests (push) Successful in 1m39s
CI / Shellcheck (push) Failing after 44s
CI / Build Go Binaries (amd64, linux, linux-amd64) (push) Failing after 1m13s
CI / Build Go Binaries (arm64, linux, linux-arm64) (push) Failing after 1m31s
fix(arm64): tr -d '[:space:]' is parsed as literal char-set by busybox 1.30.1
Ubuntu's busybox-static 1.30.1 (which we use for the ARM64 rootfs after
piCore64's BusyBox crashes in QEMU virt) doesn't recognize POSIX character
classes. `tr -d '[:space:]'` is interpreted as "delete any of the literal
characters [, :, s, p, a, c, e, ]" — so every s/p/a/c/e in module names and
sysctl keys gets eaten.

Symptoms in the boot log:
  virtio_net  -> virtio_nt   (e dropped)
  overlay     -> ovrly       (e, a dropped)
  bridge      -> bridg       (e dropped)
  nf_conntrack -> nf_onntrk  (c, a, c dropped)
  net.bridge.bridge-nf-call-iptables -> nt.bridg.bridg-nf-ll-itbl

Fix: use explicit whitespace chars `tr -d ' \t\r\n'` in both
30-kernel-modules.sh and 40-sysctl.sh. Works under any tr implementation.

Also: filter functions.sh out of the init.d stage-copy loop. It's a shared
library (sourced by init.sh), not a numbered stage. With it in init.d the
main loop runs it as a stage after stage 90, then panics with "Init
completed without exec'ing KubeSolo".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 16:02:21 -06:00

33 lines
992 B
Bash
Executable File

#!/bin/sh
# 30-kernel-modules.sh — Load required kernel modules for K8s
MODULES_LIST="/usr/lib/kubesolo-os/modules.list"
if [ ! -f "$MODULES_LIST" ]; then
log_warn "No modules list found at $MODULES_LIST"
return 0
fi
LOADED=0
FAILED=0
while IFS= read -r mod; do
# Skip comments and blank lines
case "$mod" in
'#'*|'') continue ;;
esac
# NOTE: do NOT use tr -d '[:space:]' — Ubuntu's busybox-static 1.30.1 (used
# in the ARM64 rootfs override) doesn't parse POSIX char classes and treats
# them as a literal set, deleting [, :, s, p, a, c, e, ]. Use explicit
# whitespace chars instead so the same script works under any tr.
mod="$(printf '%s' "$mod" | tr -d ' \t\r\n')"
if modprobe "$mod" 2>/dev/null; then
LOADED=$((LOADED + 1))
else
log_warn "Failed to load module: $mod (may be built-in)"
FAILED=$((FAILED + 1))
fi
done < "$MODULES_LIST"
log_ok "Loaded $LOADED modules ($FAILED failed/built-in)"