Files
stegasoo/rpi/BUILD_IMAGE.md
Aaron D. Lee d58f3c6fb6 4.1.4: QR sharing, venv tarball, flash script improvements
QR Channel Key Sharing:
- Admin-only QR generator in about.html (was visible to all)
- QR button for saved keys on account page
- Fixed about() route missing channel status vars (bug)

Pi Build Optimization:
- Pre-built venv tarball support (39MB zstd, skips 20+ min compile)
- setup.sh auto-detects and extracts tarball if present
- Strip __pycache__/tests before tarball (295MB → 208MB)

Flash Script Improvements:
- flash-image.sh now uses config.json for headless WiFi setup
- Consistent wipe prompt on both flash scripts
- pull-image.sh re-enables auto-expand before shrinking

Build Docs:
- Added zstd and jq to pre-setup apt-get
- Documented fast build option with pre-built venv

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 15:03:46 -05:00

3.5 KiB

Stegasoo Pi Image Build Workflow

Quick reference for building a distributable SD card image.

Step 1: Flash Fresh Raspbian

Use rpi-imager with these settings:

  • OS: Raspberry Pi OS Lite (64-bit)
  • Hostname: stegasoo
  • Enable SSH: Yes (password auth)
  • Username: admin
  • Password: stegasoo
  • WiFi: Configure for your network (sanitize script removes it later)

Step 2: Boot & SSH In

# Wait for Pi to boot (~60 seconds), then:
ssh admin@stegasoo.local
# or use IP from router DHCP list

Step 3: Pre-Setup

# Take ownership of /opt (for pyenv, jpegio builds)
sudo chown admin:admin /opt

# Install git and zstd (not included in Lite image)
sudo apt-get update && sudo apt-get install -y git zstd jq

Step 4: Clone & Run Setup

cd /opt
git clone -b 4.1 https://github.com/adlee-was-taken/stegasoo.git stegasoo
cd stegasoo
./rpi/setup.sh

Fast Build Option (with pre-built venv)

If you have stegasoo-venv-pi-arm64.tar.zst from a previous build:

cd /opt
git clone -b 4.1 https://github.com/adlee-was-taken/stegasoo.git stegasoo

# Copy pre-built venv (from your host machine)
# On host: scp rpi/stegasoo-venv-pi-arm64.tar.zst admin@stegasoo.local:/opt/stegasoo/rpi/

cd stegasoo
./rpi/setup.sh  # Detects tarball, extracts instead of compiling (~2 min vs 20+)

Standard build takes ~15-20 minutes and installs:

  • Python 3.12 via pyenv
  • jpegio (patched for ARM)
  • Stegasoo with web UI
  • Systemd service

Step 5: Test It Works

sudo systemctl start stegasoo
curl -k https://localhost:5000
# Should return HTML

Step 6: Sanitize for Distribution

# Full sanitize (for final image - removes WiFi, shuts down)
sudo /opt/stegasoo/rpi/sanitize-for-image.sh

# Or soft reset (for testing - keeps WiFi, reboots)
sudo /opt/stegasoo/rpi/sanitize-for-image.sh --soft

This removes:

  • WiFi credentials (unless --soft)
  • SSH host keys (regenerate on boot)
  • SSH authorized keys
  • Bash history
  • Stegasoo auth database
  • Logs and temp files

The script validates all cleanup steps before finishing.

Step 7: Copy the Image

Remove SD card, insert into your Linux machine:

# Find the SD card device (CAREFUL!)
lsblk

# Copy (replace sdX with actual device, e.g., sda)
sudo dd if=/dev/sdX of=stegasoo-rpi-$(date +%Y%m%d).img bs=4M status=progress

Step 8: Shrink & Compress

# Optional: Shrink image (saves space)
wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo ./pishrink.sh stegasoo-rpi-*.img

# Compress (zstd is faster than xz with similar ratio)
zstd -19 -T0 stegasoo-rpi-*.img

Step 9: Distribute

Upload .img.zst to GitHub Releases.

Users can flash with:

# Option 1: rpi-imager CLI (supports .zst.zip directly)
sudo rpi-imager --cli --disable-verify stegasoo-rpi-*.img.zst.zip /dev/sdX

# Option 2: flash-image.sh (auto-detects SD card, shows progress)
sudo ./rpi/flash-image.sh stegasoo-rpi-*.img.zst.zip

# Option 3: Manual dd
zstdcat stegasoo-rpi-*.img.zst | sudo dd of=/dev/sdX bs=4M status=progress

Quick Command Summary

# On Pi (after SSH):
sudo chown admin:admin /opt
sudo apt-get update && sudo apt-get install -y git
cd /opt && git clone -b 4.1 https://github.com/adlee-was-taken/stegasoo.git stegasoo
cd stegasoo && ./rpi/setup.sh
sudo systemctl start stegasoo
curl -k https://localhost:5000
sudo /opt/stegasoo/rpi/sanitize-for-image.sh

# On your machine:
sudo dd if=/dev/sdX of=stegasoo-rpi-$(date +%Y%m%d).img bs=4M status=progress
zstd -19 -T0 stegasoo-rpi-*.img