6623d4d1fd
- Fixed quick-rebuild-iso.sh paths from /hermes/ to /opt/hermes/ - Fixed ISO boot structure (uses GRUB eltorito/efi, not isolinux) - Added MBR extraction fallback for xorriso - Updated start-llama-server.bat to reference existing USB paths (bin/ollama/, Llama-3.2-1B model, llama-server-vulkan.exe) - Works with existing USB structure — no restructure needed - All bat files: ASCII text, CRLF line terminators
98 lines
3.6 KiB
Bash
Executable File
98 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Quick rebuild: extract existing ISO, update files, repack
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
BUILD_DIR="$PROJECT_DIR/build"
|
|
EXISTING_ISO="$BUILD_DIR/output/hermes-rescue.iso"
|
|
OUTPUT_DIR="$BUILD_DIR/output"
|
|
WORKDIR="${WORKDIR:-/tmp/hermes-iso-quick}"
|
|
SOURCE_DIR="$PROJECT_DIR/src"
|
|
|
|
info() { echo -e "\033[0;34m[INFO]\033[0m $*"; }
|
|
ok() { echo -e "\033[0;32m[OK]\033[0m $*"; }
|
|
die() { echo -e "\033[0;31m[ERROR]\033[0m $*"; exit 1; }
|
|
|
|
# Check prerequisites
|
|
for cmd in unsquashfs mksquashfs xorriso rsync; do
|
|
command -v "$cmd" &>/dev/null || die "$cmd not found"
|
|
done
|
|
|
|
[[ -f "$EXISTING_ISO" ]] || die "Existing ISO not found: $EXISTING_ISO"
|
|
|
|
# Clean workdir contents (handles bind mounts safely)
|
|
rm -rf "$WORKDIR" 2>/dev/null || (rm -rf "$WORKDIR"/* 2>/dev/null; true)
|
|
mkdir -p "$WORKDIR/iso-contents" "$WORKDIR/squashfs-root"
|
|
|
|
info "Mounting existing ISO..."
|
|
mkdir -p /mnt/hermes-iso-source
|
|
mount -o loop "$EXISTING_ISO" /mnt/hermes-iso-source 2>/dev/null || die "Failed to mount ISO"
|
|
|
|
info "Copying ISO contents (excluding squashfs)..."
|
|
rsync -a --exclude="casper/filesystem.squashfs" \
|
|
/mnt/hermes-iso-source/ "$WORKDIR/iso-contents/" 2>/dev/null
|
|
|
|
info "Extracting squashfs..."
|
|
cp /mnt/hermes-iso-source/casper/filesystem.squashfs "$WORKDIR/filesystem.squashfs"
|
|
umount /mnt/hermes-iso-source 2>/dev/null || true
|
|
|
|
unsquashfs -d "$WORKDIR/squashfs-root" -f "$WORKDIR/filesystem.squashfs" 2>&1 | tail -3
|
|
ok "Squashfs extracted ($(du -sh "$WORKDIR/squashfs-root" | cut -f1))"
|
|
|
|
info "Updating config.yaml..."
|
|
cp "$SOURCE_DIR/hermes/config.yaml" "$WORKDIR/squashfs-root/opt/hermes/config.yaml"
|
|
ok "config.yaml updated"
|
|
|
|
info "Updating auth.json..."
|
|
cp "$SOURCE_DIR/hermes/auth.json" "$WORKDIR/squashfs-root/opt/hermes/auth.json"
|
|
ok "auth.json updated"
|
|
|
|
info "Updating autorun.sh..."
|
|
cp "$SOURCE_DIR/hermes/autorun.sh" "$WORKDIR/squashfs-root/opt/hermes/autorun.sh"
|
|
ok "autorun.sh updated"
|
|
|
|
info "Re-packing squashfs..."
|
|
mksquashfs "$WORKDIR/squashfs-root" "$WORKDIR/iso-contents/casper/filesystem.squashfs" \
|
|
-comp lz4 -b 1M -noappend -processors 1 2>&1 | tail -5
|
|
ok "Squashfs repacked ($(du -sh "$WORKDIR/iso-contents/casper/filesystem.squashfs" | cut -f1))"
|
|
|
|
# Update filesystem.size
|
|
fs_size=$(du -sx --block-size=1 "$WORKDIR/squashfs-root" 2>/dev/null | cut -f1)
|
|
echo "$fs_size" > "$WORKDIR/iso-contents/casper/filesystem.size"
|
|
ok "filesystem.size updated"
|
|
|
|
info "Generating ISO..."
|
|
OUTPUT_ISO="$OUTPUT_DIR/hermes-rescue.iso"
|
|
EFI_IMG=$(find "$WORKDIR/iso-contents" -name "efi.img" -o -name "eltorito.img" 2>/dev/null | head -1 | sed "s|$WORKDIR/iso-contents/||")
|
|
|
|
if [[ -n "$EFI_IMG" ]]; then
|
|
xorriso -as mkisofs -r -V "HERMES_RESCUE" \
|
|
-J -joliet-long \
|
|
-isohybrid-mbr "$WORKDIR/iso-contents/isohdpfx.bin" \
|
|
-b isolinux/isolinux.bin \
|
|
-c isolinux/boot.cat \
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
-eltorito-alt-boot -e "$EFI_IMG" -no-emul-boot \
|
|
-isohybrid-gpt-basdat \
|
|
-isohybrid-apm-hfsplus \
|
|
-o "$OUTPUT_ISO" \
|
|
"$WORKDIR/iso-contents" 2>&1 | tail -5
|
|
else
|
|
xorriso -as mkisofs -r -V "HERMES_RESCUE" \
|
|
-J -joliet-long \
|
|
-isohybrid-mbr "$WORKDIR/iso-contents/isohdpfx.bin" \
|
|
-b isolinux/isolinux.bin \
|
|
-c isolinux/boot.cat \
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
-o "$OUTPUT_ISO" \
|
|
"$WORKDIR/iso-contents" 2>&1 | tail -5
|
|
fi
|
|
|
|
iso_size=$(du -h "$OUTPUT_ISO" | cut -f1)
|
|
ok "ISO generated: $OUTPUT_ISO ($iso_size)"
|
|
|
|
info "Cleaning up..."
|
|
# rm -rf workdir (skip - bind mount)
|
|
ok "Done!"
|