clawdie-iso/installerconfig
Sam & Claude 904dd58373 Enable mac_do framework during bootstrap (Codex)
Configure FreeBSD 15 installs to load mac_do with an empty rule set for future narrowly scoped UID transitions.
2026-06-04 20:04:22 +02:00

72 lines
2.4 KiB
Text

PARTITIONS=DEFAULT
DISTRIBUTIONS="kernel.txz base.txz"
export nonInteractive="YES"
#!/bin/sh
# installerconfig — bsdinstall post-install hook
#
# bsdinstall sources this file automatically after base system installation
# completes. Runs in the context of the live USB environment, with the
# target HDD mounted at /mnt.
#
# PREAMBLE (for bsdinstall scripting):
# Set ZFS pool name to "clawdie" (project-specific, enables auto-detection)
export ZFSBOOT_POOL_NAME="clawdie"
#
# SETUP SCRIPT:
#
# Responsibilities:
# 1. Copy firstboot payload from USB to installed HDD
# 2. Enable the clawdie-firstboot rc.d service (runs once on first HDD boot)
# 3. That's it — all real work happens in firstboot.sh on first boot
set -e
set_config_line() {
_file="$1"
_assignment="$2"
_name=$(echo "$_assignment" | cut -d= -f1)
mkdir -p "$(dirname "$_file")"
touch "$_file"
if grep -q "^${_name}=" "$_file" 2>/dev/null; then
sed -i '' "s|^${_name}=.*|${_assignment}|" "$_file"
else
echo "$_assignment" >> "$_file"
fi
}
USB_SHARE="/usr/local/share/clawdie-iso"
HDD_SHARE="/mnt/usr/local/share/clawdie-iso"
HDD_RCD="/mnt/usr/local/etc/rc.d"
echo "clawdie-iso: injecting firstboot payload..."
# Copy firstboot scripts
mkdir -p "$HDD_SHARE"
cp -r "${USB_SHARE}/firstboot" "${HDD_SHARE}/"
cp -r "${USB_SHARE}/packages" "${HDD_SHARE}/"
cp "${USB_SHARE}/clawdie-ai.tar.gz" "${HDD_SHARE}/"
cp "${USB_SHARE}/build.cfg" "${HDD_SHARE}/"
# Make all firstboot shell modules executable
chmod +x "${HDD_SHARE}/firstboot/firstboot.sh"
for sh in "${HDD_SHARE}/firstboot/shell-"*.sh; do
chmod +x "$sh"
done
chmod +x "${HDD_SHARE}/firstboot/zfs-pool-detect.sh" 2>/dev/null || true
chmod +x "${HDD_SHARE}/firstboot/zfs-pool-migrate.sh" 2>/dev/null || true
chmod +x "${HDD_SHARE}/firstboot/maintenance-mode.sh" 2>/dev/null || true
# Install firstboot rc.d service
mkdir -p "$HDD_RCD"
cp "${USB_SHARE}/firstboot/rc.d/clawdie-firstboot" "${HDD_RCD}/clawdie-firstboot"
chmod +x "${HDD_RCD}/clawdie-firstboot"
# Enable mac_do framework at first HDD boot with no credential grants yet.
set_config_line /mnt/boot/loader.conf 'mac_do_load="YES"'
set_config_line /mnt/etc/sysctl.conf 'security.mac.do.rules='
# Enable service in rc.conf on HDD
echo 'clawdie_firstboot_enable="YES"' >> /mnt/etc/rc.conf
echo "clawdie-iso: firstboot payload installed. Rebooting to HDD..."