· 3 months ago · Jun 28, 2025, 08:45 PM
1#!/bin/bash
2
3# This script prepares a flash drive for a headless Raspberry Pi setup.
4
5# --- Configuration ---
6# Replace with your desired username
7USERNAME="pi"
8# Replace with your desired password
9PASSWORD="raspberry"
10# Replace with your Wi-Fi SSID
11WIFI_SSID="YOUR_WIFI_SSID"
12# Replace with your Wi-Fi password
13WIFI_PASSWORD="YOUR_WIFI_PASSWORD"
14
15# --- Script ---
16
17# Create userconf.txt for username and password
18echo "$USERNAME:$(echo $PASSWORD | openssl passwd -6 -stdin)" > userconf.txt
19
20# Create wpa_supplicant.conf for Wi-Fi
21cat > wpa_supplicant.conf << EOL
22ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
23update_config=1
24country=US
25
26network={
27 ssid="$WIFI_SSID"
28 psk="$WIFI_PASSWORD"
29}
30EOL
31
32# Enable SSH
33touch ssh
34
35echo "Setup complete. Please copy all generated files to the boot partition of your Raspberry Pi's SD card."
36