bbc6fb1 chowned the directory correctly but it stayed empty at build
time, and bee_layer_classify (squashfs-layers.sh) only tracks regular
files and symlinks via `find ... -type f -o -type l` — an empty
directory is silently dropped from every layer's rsync --files-from
list and never reaches the built ISO. dcgmi diag's deployment check
still failed with DCGM_FR_FILE_CREATE_PERMISSIONS after rebuilding on
top of that fix because the directory simply didn't exist at boot.
Seed /var/log/nvidia-dcgm/.keep so the directory rides along the
classifier as an implied parent (rsync -a preserves its ownership),
and stop 9999-slim's log sweep from deleting that marker before the
classifier ever sees it.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
110 lines
4.5 KiB
Bash
Executable File
110 lines
4.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# 9000-bee-setup.hook.chroot — runs inside Debian chroot during live-build
|
|
# Enables bee systemd services and configures the live environment.
|
|
set -e
|
|
|
|
echo "=== bee chroot setup ==="
|
|
|
|
GPU_VENDOR=$(cat /etc/bee-gpu-vendor 2>/dev/null || echo nvidia)
|
|
echo "=== GPU vendor: ${GPU_VENDOR} ==="
|
|
|
|
ensure_bee_console_user() {
|
|
if id bee >/dev/null 2>&1; then
|
|
usermod -d /home/bee -s /bin/bash bee 2>/dev/null || true
|
|
else
|
|
useradd -d /home/bee -m -s /bin/bash -U bee
|
|
fi
|
|
|
|
mkdir -p /home/bee
|
|
chown -R bee:bee /home/bee
|
|
echo "bee:eeb" | chpasswd
|
|
groupadd -f ipmi 2>/dev/null || true
|
|
usermod -aG sudo,video,input,render,ipmi bee 2>/dev/null || true
|
|
}
|
|
|
|
ensure_bee_console_user
|
|
|
|
# Enable common bee services
|
|
systemctl enable bee-hpc-tuning.service
|
|
systemctl enable bee-network.service
|
|
systemctl enable bee-preflight.service
|
|
systemctl enable bee-audit.service
|
|
systemctl enable bee-web.service
|
|
systemctl enable bee-sshsetup.service
|
|
systemctl enable bee-blackbox.service
|
|
systemctl enable bee-selfheal.timer
|
|
systemctl enable bee-boot-status.service
|
|
systemctl enable ssh.service
|
|
systemctl enable lightdm.service 2>/dev/null || true
|
|
systemctl enable qemu-guest-agent.service 2>/dev/null || true
|
|
systemctl enable serial-getty@ttyS0.service 2>/dev/null || true
|
|
systemctl enable serial-getty@ttyS1.service 2>/dev/null || true
|
|
systemctl enable bee-journal-mirror@ttyS1.service 2>/dev/null || true
|
|
|
|
# Enable GPU-vendor specific services
|
|
if [ "$GPU_VENDOR" = "nvidia" ]; then
|
|
systemctl enable nvidia-dcgm.service 2>/dev/null || true
|
|
systemctl enable nvidia-fabricmanager.service 2>/dev/null || true
|
|
systemctl enable bee-nvidia.service
|
|
|
|
# nvidia-dcgm.service runs `nv-hostengine --service-account nvidia-dcgm`,
|
|
# which drops privileges to that account for all file I/O and writes
|
|
# diagnostics to DCGM_HOME_DIR (/var/log/nvidia-dcgm, per the packaged
|
|
# unit's Environment=). The package's own postinst already creates and
|
|
# chowns this directory correctly — but it's empty at that point, and
|
|
# lib/squashfs-layers.sh's classifier only tracks regular files and
|
|
# symlinks (`find ... -type f -o -type l`), so an empty directory is
|
|
# silently dropped from every layer's rsync --files-from list and never
|
|
# reaches the built ISO at all. `dcgmi diag`'s deployment check then
|
|
# fails with DCGM_FR_FILE_CREATE_PERMISSIONS at boot because the
|
|
# directory doesn't exist, regardless of ownership. Re-create it and
|
|
# seed one real file so it rides along the classifier and rsync -a
|
|
# recreates the parent directory (with this ownership) as an implied
|
|
# parent.
|
|
if id nvidia-dcgm >/dev/null 2>&1; then
|
|
install -d -o nvidia-dcgm -g nvidia-dcgm -m 0755 /var/log/nvidia-dcgm
|
|
install -o nvidia-dcgm -g nvidia-dcgm -m 0644 /dev/null /var/log/nvidia-dcgm/.keep
|
|
fi
|
|
elif [ "$GPU_VENDOR" = "amd" ]; then
|
|
# ROCm symlinks (packages install to /opt/rocm-*/bin/)
|
|
for tool in rocm-smi rocm-bandwidth-test rvs; do
|
|
if [ ! -e /usr/local/bin/${tool} ]; then
|
|
bin_path="$(find /opt -path "*/bin/${tool}" -type f 2>/dev/null | sort | tail -1)"
|
|
[ -n "${bin_path}" ] && ln -sf "${bin_path}" /usr/local/bin/${tool}
|
|
fi
|
|
done
|
|
fi
|
|
# nogpu: no GPU services needed
|
|
|
|
# Ensure scripts are executable
|
|
chmod +x /usr/local/bin/bee-hpc-tuning 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-network.sh 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-sshsetup 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-smoketest 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-log-run 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-selfheal 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-boot-status 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-install 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-gui-gate 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-remount-medium 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-check-nvswitch 2>/dev/null || true
|
|
if [ "$GPU_VENDOR" = "nvidia" ]; then
|
|
chmod +x /usr/local/bin/bee-nvidia-load 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-gpu-burn 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-john-gpu-stress 2>/dev/null || true
|
|
chmod +x /usr/local/bin/bee-nccl-gpu-stress 2>/dev/null || true
|
|
fi
|
|
|
|
# Reload udev rules
|
|
udevadm control --reload-rules 2>/dev/null || true
|
|
|
|
# Create export directory
|
|
mkdir -p /appdata/bee/export
|
|
|
|
if [ -f /etc/sudoers.d/bee ]; then
|
|
chmod 0440 /etc/sudoers.d/bee
|
|
fi
|
|
|
|
echo "=== bee chroot setup complete (${GPU_VENDOR}) ==="
|