#!/bin/bash # Helper script to chroot into the netboot rootfs for testing/tweaking set -e ROOTFS="/srv/netboot/build/rootfs" if [ ! -d "$ROOTFS" ]; then echo "Error: $ROOTFS does not exist" echo "Run build-image.sh first to create the rootfs" exit 1 fi # Function to cleanup mounts on exit cleanup() { echo "" echo "Cleaning up mounts..." umount "$ROOTFS/proc" 2>/dev/null || true umount "$ROOTFS/sys" 2>/dev/null || true umount "$ROOTFS/dev/pts" 2>/dev/null || true umount "$ROOTFS/dev" 2>/dev/null || true echo "Unmounted. You can now rebuild the squashfs image." } trap cleanup EXIT echo "Mounting filesystems for chroot..." mount -t proc /proc "$ROOTFS/proc" mount -t sysfs /sys "$ROOTFS/sys" mount --bind /dev "$ROOTFS/dev" mount --bind /dev/pts "$ROOTFS/dev/pts" echo "Entering chroot environment..." echo "Type 'exit' when done to return and cleanup mounts" echo "" # Enter chroot chroot "$ROOTFS" /bin/bash # cleanup() will run automatically on exit