The USB/ISO builder consists of several shell scripts that create bootable media for offline LLM environments. While functional, there are opportunities for improvement.
build-iso.sh and build-usb.sh share similar logic for:
set -e but lack proper cleanup on failureGoal: Create shared library of functions
Tasks:
lib/common.sh with shared functions:
check_deps() - dependency checkingverify_iso() - ISO validationcleanup() - temp directory cleanuplog_info(), log_warn(), log_error() - loggingcheck_root() - root permission checklib/cache.sh for caching logic:
cache_get() - retrieve from cachecache_put() - store in cachecache_verify() - verify cache integritycache_clean() - clean cachelib/container.sh for container operations:
container_pull() - pull imagecontainer_save() - save to tarcontainer_load() - load from tarEstimated effort: 4-6 hours
Goal: Centralize configuration
Tasks:
config.sh with all configurable values:
# config.sh
ISO_NAME="llm-station-um790pro.iso"
DISTRO="fedora"
BASE_ISO_URL_FEDORA="..."
BASE_ISO_URL_UBUNTU="..."
CONTAINER_IMAGES=("ollama/ollama:rocm" "ghcr.io/open-webui/open-webui:main")
RAM_DEFAULT="8G"
CPUS_DEFAULT="4"
Support .env file for user overrides
Estimated effort: 2-3 hours
Goal: Robust error handling with proper cleanup
Tasks:
cleanup() {
[ -d "$WORK_DIR" ] && rm -rf "$WORK_DIR"
[ -n "$MOUNT_POINT" ] && umount "$MOUNT_POINT" 2>/dev/null
}
trap cleanup EXIT
Add error codes for different failure types
Implement --dry-run mode for testing
--verbose and --quiet modesEstimated effort: 3-4 hours
Goal: Plugin system for different base distros
Tasks:
distros/ directory with per-distro configs:
distros/
├── fedora.sh
├── ubuntu.sh
└── arch.sh
DISTRO_ISO_URLDISTRO_PACKAGESdistro_post_install()distro_boot_config()Estimated effort: 4-5 hours
Goal: Automated testing for build scripts
Tasks:
tests/ directory with test scripts:
tests/
├── test_common.sh
├── test_cache.sh
├── test_iso_build.sh
└── run_tests.sh
Use bats (Bash Automated Testing System) or simple assertions
Add mock mode for testing without actual downloads
Estimated effort: 6-8 hours
Goal: Python CLI for better integration with streamware
Tasks:
streamware/cli/iso_builder.py:
@click.command()
@click.option('--distro', default='fedora')
@click.option('--output', default='output/')
def build_iso(distro, output):
...
Add to main CLI: sq iso-build, sq iso-test
Better progress reporting with rich/tqdm
Estimated effort: 8-10 hours
environments/usb-builder/
├── lib/
│ ├── common.sh # Shared functions
│ ├── cache.sh # Caching logic
│ ├── container.sh # Container operations
│ └── boot.sh # Boot configuration
├── distros/
│ ├── fedora.sh # Fedora-specific
│ ├── ubuntu.sh # Ubuntu-specific
│ └── arch.sh # Arch-specific
├── templates/
│ ├── first-boot.sh # First boot template
│ ├── autostart.desktop
│ └── grub.cfg # GRUB config template
├── tests/
│ ├── test_common.sh
│ ├── test_cache.sh
│ └── run_tests.sh
├── cache/ # Downloaded files
├── output/ # Built ISOs
├── config.sh # Configuration
├── build-iso.sh # Main ISO builder
├── build-usb.sh # Main USB builder
├── test-iso.sh # ISO tester
├── diagnose.sh # Diagnostics
└── README.md
| Phase | Priority | Effort | Impact |
|---|---|---|---|
| 1. Common Functions | High | 4-6h | High |
| 2. Configuration | High | 2-3h | Medium |
| 3. Error Handling | High | 3-4h | High |
| 4. Distro Plugins | Medium | 4-5h | Medium |
| 5. Testing | Medium | 6-8h | High |
| 6. Python Wrapper | Low | 8-10h | Medium |
Total estimated effort: 27-36 hours