scripts
This commit is contained in:
56
rebuild-squashfs.sh
Executable file
56
rebuild-squashfs.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/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 <<EOF
|
||||
Build Date: $(date)
|
||||
Ubuntu Version: Noble (24.04)
|
||||
Kernel: $(ls $BUILD_DIR/rootfs/boot/vmlinuz-* | sed 's/.*vmlinuz-//')
|
||||
Image Size: $(du -h $IMAGE_DIR/$VERSION/filesystem.squashfs | awk '{print $1}')
|
||||
Rebuilt from modified rootfs
|
||||
EOF
|
||||
|
||||
echo "Image created: $IMAGE_DIR/$VERSION/"
|
||||
ls -lh $IMAGE_DIR/$VERSION/
|
||||
|
||||
# Update latest symlink
|
||||
ln -sfn $VERSION $IMAGE_DIR/latest
|
||||
|
||||
# Deploy to HTTP directory
|
||||
echo "Deploying to HTTP directory..."
|
||||
rsync -av $IMAGE_DIR/$VERSION/ $HTTP_DIR/
|
||||
ln -sfn $VERSION $HTTP_DIR/latest
|
||||
|
||||
echo ""
|
||||
echo "Build complete! Version: $VERSION"
|
||||
echo "Files available at: $HTTP_DIR/"
|
||||
echo ""
|
||||
echo "Old versions kept in: $IMAGE_DIR/"
|
||||
Reference in New Issue
Block a user