Zero-config Pi Imager setup. Auto-detects WiFi, fetches passwords from keychain, injects SSH keys.
./gen server # 1. Generate + auto-serve (URL in clipboard!)
# 2. Pi Imager → Choose OS → Cmd+Shift+X → Use custom URL → Paste (Cmd+V)
# 3. Flash!./gen # Server config (headless)
./gen desktop # Desktop config (GUI)That's it! The script automatically:
- ✅ Detects your WiFi network
- ✅ Fetches WiFi password from macOS Keychain (one prompt per session)
- ✅ Finds your SSH key from
~/.ssh/ - ✅ Generates optimized config
- ✅ Starts HTTP server
- ✅ Copies URL to clipboard
./gen server
./gen server pi5backup # Custom hostnameRecommended OS: Raspberry Pi OS Lite (64-bit) - No desktop
Optimizations:
- Bluetooth disabled
- Audio disabled
- GPU memory: 16MB (minimal)
- Splash screen disabled
- Fast boot (0s delay)
- SSH-only access
Use for: Web servers, Docker hosts, headless automation
./gen desktop
./gen desktop pi5dev # Custom hostnameRecommended OS: Raspberry Pi OS (64-bit) - Full desktop
Optimizations:
- GPU memory: 256MB
- HDMI hotplug enabled
- Overscan disabled
- Full desktop environment
Use for: Development workstation, media center, GUI apps
PI_PASSWORD=mypass ./gen server
PI_PASSWORD=x SSID=MyWifi WIFI_PASS=secret ./genCreate secrets.env:
PI_PASSWORD=byledozimyThe script will auto-load it if present.
- Run:
./gen server(or./gen desktop)- HTTP server starts automatically
- URL copied to clipboard
- Open Raspberry Pi Imager
- Choose OS:
- Server: Raspberry Pi OS Lite (64-bit)
- Desktop: Raspberry Pi OS (64-bit) with desktop
- Choose Storage: Your SD card
- Press
Cmd+Shift+X(Mac) orCtrl+Shift+X(Windows/Linux) - Select "Use custom URL"
- Paste (Cmd+V) - URL already in clipboard!
- Click "Yes" to apply settings
- Flash!
If you prefer not to use the HTTP server:
- Run:
./gen serverthen Ctrl+C to stop server - Open Raspberry Pi Imager
- Choose appropriate OS
- Choose Storage
- Press
Cmd+Shift+X→ "Load from file" →/tmp/pi-config-server.json - Flash!
- SSH key never committed
- WiFi password from keychain (macOS prompts once per session)
- Optional
secrets.envis gitignored - Password auth disabled (SSH key only)
config-server.json- Server templateconfig-desktop.json- Desktop templategen- Magic generator scriptsecrets.env- Optional password storage (gitignored)
- Hostname:
pi5main(customizable) - Username:
rege - SSH: Enabled (public key only)
- WiFi: Auto-detected
- Timezone:
Europe/Warsaw - Keyboard:
us
- macOS (for WiFi/keychain auto-detection)
- SSH key in
~/.ssh/id_ed25519.pubor~/.ssh/id_rsa.pub - Python 3 (for HTTP server - built into macOS)
Linux users: Script will prompt for WiFi password.
Change defaults: Edit config-server.json or config-desktop.json
Multiple Pis: Run script multiple times with different hostnames
./gen server pi5web
./gen server pi5db
./gen desktop pi5devEach generates a separate config file.
Multiple configs: Each ./gen command restarts the server with the new config URL in clipboard.
| Config Type | Recommended OS | Use Case |
|---|---|---|
| Server | Raspberry Pi OS Lite (64-bit) | Web servers, Docker, headless automation |
| Desktop | Raspberry Pi OS (64-bit) | Development, GUI apps, media center |
| Server | Ubuntu Server 24.04 LTS | Advanced server setups, Kubernetes |
| Desktop | Raspberry Pi OS Full (64-bit) | Maximum software, LibreOffice, games |
💡 Tip: Always choose 64-bit OS for Pi 4/5 for better performance.
After Pi boots, install infrastructure:
ssh rege@pi5main.local
git clone https://github.com/rockcodelabs/infrastructure.git
cd infrastructure
./scripts/setup-pi.sh