Files
netboot/Makefile
Torbjørn Lindahl 3f191d8f93 Add NVMe storage auto-setup, sops secrets, fix SSH permissions
- setup-node-storage service auto-partitions NVMe for containerd/longhorn
- Root password encrypted with sops/age, decrypted during build
- Fix SSH host key permissions (0600) so sshd actually starts
- Disable SSH socket activation for reliable boot
- Add OPERATIONS.md with runbook
- Makefile tracks source dependencies
2026-02-06 00:58:38 +01:00

78 lines
2.6 KiB
Makefile

.PHONY: deploy clean help check-nas all
NAS_HOST=phoenix
NAS_PATH=/srv/netboot
SCRIPT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Source files that trigger a rebuild
BUILD_SOURCES := $(SCRIPT_DIR)/build-image.sh \
$(wildcard $(SCRIPT_DIR)/initramfs/*) \
$(wildcard $(SCRIPT_DIR)/initramfs/*/*) \
$(wildcard $(SCRIPT_DIR)/files/*) \
$(wildcard $(SCRIPT_DIR)/secrets/*.yaml)
# Build artifact (used as target for dependency tracking)
BUILD_ARTIFACT := $(SCRIPT_DIR)/http/filesystem.squashfs
help:
@echo "Netboot image build and deployment"
@echo ""
@echo "Targets:"
@echo " make build - Build the netboot image (kernel, initramfs, squashfs)"
@echo " make deploy - Sync built artifacts to NAS ($(NAS_HOST))"
@echo " make all - Build and deploy in one step"
@echo " make check-nas - Verify NAS is reachable"
@echo " make clean - Remove build artifacts"
@echo ""
@echo "Configuration:"
@echo " NAS_HOST=$(NAS_HOST)"
@echo " NAS_PATH=$(NAS_PATH)"
@echo ""
check-nas:
@echo "Checking NAS connectivity..."
@ping -c 1 $(NAS_HOST) > /dev/null 2>&1 && echo "✓ NAS is reachable" || (echo "✗ Cannot reach $(NAS_HOST)"; exit 1)
# Build depends on source files - only rebuilds if sources changed
$(BUILD_ARTIFACT): $(BUILD_SOURCES)
@echo "Building netboot image..."
@echo "This will take 15-30 minutes..."
sudo $(SCRIPT_DIR)/build-image.sh
@echo ""
@echo "Build complete!"
@echo "Artifacts ready in $(SCRIPT_DIR)/http/"
@du -sh $(SCRIPT_DIR)/http/*
build: $(BUILD_ARTIFACT)
deploy: check-nas
@echo "Deploying to NAS ($(NAS_HOST):$(NAS_PATH))..."
@echo "Syncing http/ directory..."
rsync -avz --delete $(SCRIPT_DIR)/http/ $(NAS_HOST):$(NAS_PATH)/http/
@echo "Syncing tftp/ directory (iPXE bootloader)..."
rsync -avz $(SCRIPT_DIR)/tftp/ $(NAS_HOST):$(NAS_PATH)/tftp/
@echo ""
@echo "✓ Deployment complete!"
@echo "Images are now live on $(NAS_HOST)"
@ssh $(NAS_HOST) "ls -lh $(NAS_PATH)/http/ | grep -E '(vmlinuz|initrd|squashfs)'"
all: build deploy
@echo ""
@echo "✓ Build and deployment complete!"
clean:
@echo "Cleaning build artifacts..."
@if [ -d "$(SCRIPT_DIR)/build/rootfs" ]; then \
echo "Unmounting any stray mounts from $(SCRIPT_DIR)/build/rootfs..."; \
mount | grep "$(SCRIPT_DIR)/build/rootfs" | awk '{print $$3}' | while read mount; do \
echo " Unmounting $$mount"; \
sudo umount -l "$$mount" 2>/dev/null || true; \
done; \
fi
@echo "Removing build directories..."
sudo rm -rf $(SCRIPT_DIR)/build/rootfs
sudo rm -rf $(SCRIPT_DIR)/images
@echo "✓ Cleaned!"
.DEFAULT_GOAL := help