#!/bin/bash # Rebuild squashfs image from existing rootfs (after making changes) set -e BUILD_DIR="/srv/netboot/build" IMAGE_DIR="/srv/netboot/images" HTTP_DIR="/srv/netboot/http" VERSION=$(date +%Y%m%d-%H%M) if [ ! -d "$BUILD_DIR/rootfs" ]; then echo "Error: $BUILD_DIR/rootfs does not exist" echo "Run build-image.sh first to create the rootfs" exit 1 fi echo "Rebuilding squashfs image version $VERSION" # Copy kernel and initrd mkdir -p $IMAGE_DIR/$VERSION cp $BUILD_DIR/rootfs/boot/vmlinuz-* $IMAGE_DIR/$VERSION/vmlinuz cp $BUILD_DIR/rootfs/boot/initrd.img-* $IMAGE_DIR/$VERSION/initrd.img echo "Creating squashfs image..." mksquashfs $BUILD_DIR/rootfs \ $IMAGE_DIR/$VERSION/filesystem.squashfs \ -comp xz \ -Xbcj x86 \ -b 1M \ -noappend # Create version info cat > $IMAGE_DIR/$VERSION/version.txt <