Phase 1: scaffold lab.sh, config and preflight checks
Move the archived 2002 site into site-src/ so the lab README can take the repo root. Add lab.conf, the lab.sh dispatcher, a qemu backend and the check/init verbs. No VM is created yet.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# shellcheck shell=bash
|
||||
# cmd_init — create the storage layout. No ISOs downloaded yet (phase 3).
|
||||
|
||||
cmd_init() {
|
||||
step "storage layout"
|
||||
mkdir -p "$LAB_ROOT"/images "$LAB_ROOT"/seeds "$LAB_ROOT"/run "$LAB_ROOT"/logs
|
||||
ok "LAB_ROOT ${LAB_ROOT}"
|
||||
|
||||
# chattr +C must be set on the directory *before* any file is created in it,
|
||||
# otherwise btrfs keeps CoW for the existing tree.
|
||||
if [[ $(fstype_of "$LAB_ROOT") == btrfs ]]; then
|
||||
mkdir -p "$LAB_ROOT/images/base" "$LAB_ROOT/images/overlays"
|
||||
if chattr +C "$LAB_ROOT/images" 2>/dev/null; then
|
||||
if lsattr -d "$LAB_ROOT/images" 2>/dev/null | awk '{print $1}' | grep -q 'C'; then
|
||||
ok "images/ : +C set (CoW disabled)"
|
||||
else
|
||||
warn "images/ : chattr +C did not stick"
|
||||
fi
|
||||
else
|
||||
warn "images/ : chattr +C failed (btrfs?)"
|
||||
fi
|
||||
else
|
||||
mkdir -p "$LAB_ROOT/images/base" "$LAB_ROOT/images/overlays"
|
||||
info " images/ : $(fstype_of "$LAB_ROOT") — no +C needed"
|
||||
fi
|
||||
|
||||
step "iso cache"
|
||||
if is_mounted "$LAB_ISO_CACHE" || is_mounted "$(dirname "$LAB_ISO_CACHE")"; then
|
||||
mkdir -p "$LAB_ISO_CACHE"
|
||||
ok "ISO cache ${LAB_ISO_CACHE}"
|
||||
else
|
||||
warn "ISO cache parent $(dirname "$LAB_ISO_CACHE") is not mounted — skipped"
|
||||
fi
|
||||
|
||||
step "directories"
|
||||
for d in images/base images/overlays seeds run logs; do
|
||||
printf ' %-24s %s\n' "$d" "$([[ -d $LAB_ROOT/$d ]] && echo present || echo missing)"
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
ok "layout ready — next: ./lab.sh check"
|
||||
}
|
||||
Reference in New Issue
Block a user