Skip to content

rockcodelabs/raspberry-pi-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Auto Config

Zero-config Pi Imager setup. Auto-detects WiFi, fetches passwords from keychain, injects SSH keys.

⚡ 30-Second Setup

./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!

🚀 Quick Start

./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

📋 Config Types

🖥️ Server (Headless)

./gen server
./gen server pi5backup  # Custom hostname

Recommended 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

🖥️ Desktop (GUI)

./gen desktop
./gen desktop pi5dev  # Custom hostname

Recommended 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

🔧 Manual Override

Environment Variables

PI_PASSWORD=mypass ./gen server
PI_PASSWORD=x SSID=MyWifi WIFI_PASS=secret ./gen

Secrets File (Optional)

Create secrets.env:

PI_PASSWORD=byledozimy

The script will auto-load it if present.

📥 Load in Pi Imager

Automatic (Recommended)

  1. Run: ./gen server (or ./gen desktop)
    • HTTP server starts automatically
    • URL copied to clipboard
  2. Open Raspberry Pi Imager
  3. Choose OS:
    • Server: Raspberry Pi OS Lite (64-bit)
    • Desktop: Raspberry Pi OS (64-bit) with desktop
  4. Choose Storage: Your SD card
  5. Press Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux)
  6. Select "Use custom URL"
  7. Paste (Cmd+V) - URL already in clipboard!
  8. Click "Yes" to apply settings
  9. Flash!

Manual (Load from File)

If you prefer not to use the HTTP server:

  1. Run: ./gen server then Ctrl+C to stop server
  2. Open Raspberry Pi Imager
  3. Choose appropriate OS
  4. Choose Storage
  5. Press Cmd+Shift+X → "Load from file" → /tmp/pi-config-server.json
  6. Flash!

🔐 Security

  • SSH key never committed
  • WiFi password from keychain (macOS prompts once per session)
  • Optional secrets.env is gitignored
  • Password auth disabled (SSH key only)

📁 Files

  • config-server.json - Server template
  • config-desktop.json - Desktop template
  • gen - Magic generator script
  • secrets.env - Optional password storage (gitignored)

⚙️ Default Settings

  • Hostname: pi5main (customizable)
  • Username: rege
  • SSH: Enabled (public key only)
  • WiFi: Auto-detected
  • Timezone: Europe/Warsaw
  • Keyboard: us

🛠️ Requirements

  • macOS (for WiFi/keychain auto-detection)
  • SSH key in ~/.ssh/id_ed25519.pub or ~/.ssh/id_rsa.pub
  • Python 3 (for HTTP server - built into macOS)

Linux users: Script will prompt for WiFi password.

💡 Tips

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 pi5dev

Each generates a separate config file.

Multiple configs: Each ./gen command restarts the server with the new config URL in clipboard.

🎯 OS Selection Guide

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.


⏭️ What's Next?

After Pi boots, install infrastructure:

ssh rege@pi5main.local
git clone https://github.com/rockcodelabs/infrastructure.git
cd infrastructure
./scripts/setup-pi.sh

See: https://github.com/rockcodelabs/infrastructure

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages