Add reimage bootstrap: deploy.sh, setup_wifi.sh, fix setup.sh enable/reinstall, idempotent DB inserts

This commit is contained in:
Cobra
2026-04-07 13:20:15 -04:00
parent 0f754cfb7f
commit 7070f6548c
4 changed files with 186 additions and 16 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Write a NetworkManager WiFi profile to an unmounted Armbian SD card.
# Run this on the machine where the SD card is mounted BEFORE first boot.
#
# Usage: bash scripts/setup_wifi.sh SSID PASSPHRASE [MOUNT_POINT]
# MOUNT_POINT defaults to /media/$USER/armbi_root
set -euo pipefail
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
info() { echo -e "${GREEN}[+]${NC} $*"; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
error() { echo -e "${RED}[-]${NC} $*"; exit 1; }
SSID="${1:-}"
PASSPHRASE="${2:-}"
MOUNT="${3:-/media/${USER:-root}/armbi_root}"
[[ -z "$SSID" || -z "$PASSPHRASE" ]] && {
echo "Usage: $0 SSID PASSPHRASE [MOUNT_POINT]"
echo " MOUNT_POINT defaults to /media/\$USER/armbi_root"
exit 1
}
[[ -d "$MOUNT" ]] || error "Mount point not found: $MOUNT — is the SD card mounted?"
NM_DIR="${MOUNT}/etc/NetworkManager/system-connections"
NM_FILE="${NM_DIR}/wifi-bb.nmconnection"
mkdir -p "$NM_DIR"
cat > "$NM_FILE" << EOF
[connection]
id=wifi-bb
type=wifi
autoconnect=true
[wifi]
mode=infrastructure
ssid=${SSID}
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=${PASSPHRASE}
[ipv4]
method=auto
[ipv6]
method=disabled
EOF
chmod 600 "$NM_FILE"
info "WiFi profile written to ${NM_FILE}"
info "SSID: ${SSID}"
echo ""
info "After first boot, device should connect automatically."
warn "If it doesn't connect, SSH in via Ethernet or serial and run:"
warn " nmcli dev wifi connect '${SSID}' password '<passphrase>'"
echo ""
info "Once connected, deploy BigBrother with:"
info " bash scripts/deploy.sh root@<DEVICE_IP> --enable-service"