firmware.sh: if no local firmware-latest.fl, fetch https://zos.grid.tf/store/flists/firmware-latest.fl using wget or busybox wget; then mount via rfs. modules.sh: if no local modules-6.16.5-arch1-1.fl, fetch https://zos.grid.tf/store/flists/modules-6.16.5-arch1-1-Zero-OS.fl using wget or busybox wget; then mount via rfs. Keep env overrides MODULES_FLIST/FIRMWARE_FLIST and RFS_BIN semantics.
64 lines
1.6 KiB
Bash
64 lines
1.6 KiB
Bash
#!/bin/sh
|
|
# rfs mount modules flist over /lib/modules/$(uname -r) (plain S3 route embedded in the .fl)
|
|
# Looks for modules-$(uname -r).fl in known locations; can be overridden via MODULES_FLIST env.
|
|
|
|
set -eu
|
|
|
|
log() { echo "[rfs-modules] $*"; }
|
|
|
|
RFS_BIN="${RFS_BIN:-rfs}"
|
|
KVER="$(uname -r)"
|
|
TARGET="/lib/modules/${KVER}"
|
|
BASE_URL="${FLISTS_BASE_URL:-https://zos.grid.tf/store/flists}"
|
|
|
|
# Allow override via env
|
|
if [ -n "${MODULES_FLIST:-}" ] && [ -f "${MODULES_FLIST}" ]; then
|
|
FL="${MODULES_FLIST}"
|
|
else
|
|
# Candidate paths for the flist manifest
|
|
for p in \
|
|
"/etc/rfs/modules-${KVER}.fl" \
|
|
"/var/lib/rfs/modules-${KVER}.fl" \
|
|
"/root/modules-${KVER}.fl" \
|
|
"/modules-${KVER}.fl" \
|
|
; do
|
|
if [ -f "$p" ]; then
|
|
FL="$p"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ -z "${FL:-}" ]; then
|
|
# Try remote fetch as a fallback (modules-<uname -r>-Zero-OS.fl)
|
|
mkdir -p /etc/rfs
|
|
FL="/etc/rfs/modules-${KVER}.fl"
|
|
URL="${BASE_URL}/modules-${KVER}-Zero-OS.fl"
|
|
log "modules-${KVER}.fl not found locally; fetching ${URL}"
|
|
|
|
if command -v wget >/dev/null 2>&1; then
|
|
wget -q -O "${FL}" "${URL}" || true
|
|
elif command -v busybox >/dev/null 2>&1; then
|
|
busybox wget -q -O "${FL}" "${URL}" || true
|
|
else
|
|
log "no wget available to fetch ${URL}"
|
|
fi
|
|
|
|
if [ ! -s "${FL}" ]; then
|
|
log "failed to fetch ${URL}; skipping mount"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Ensure target directory exists
|
|
mkdir -p "$TARGET"
|
|
|
|
# Skip if already mounted
|
|
if mountpoint -q "$TARGET" 2>/dev/null; then
|
|
log "already mounted: $TARGET"
|
|
exit 0
|
|
fi
|
|
|
|
# Perform the mount
|
|
log "mounting ${FL} -> ${TARGET}"
|
|
exec "$RFS_BIN" mount -m "$FL" "$TARGET" |