Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

flash-mac.sh: write preset wifi_creds + preserve user-saved networks

Previous flashes on macOS shipped the USB with NO wifi_creds.json at
all — so every freshly-flashed stick booted a device that couldn't
connect to any of the 4 standard presets the Linux oven/ac-os path
bakes in, and re-flashes wiped out any user-added networks from the
prior session.

Two-step mirror of ac_media_write_global_wifi_creds +
ac_media_merge_wifi_creds from scripts/media-layout.sh:

1. Preset list, inlined in the script (kept in sync with the JSON in
media-layout.sh:140 — aesthetic.computer / ATT2AWTpcr / GettyLink /
Tondo_Guest). Written on every flash even for a never-flashed stick.

2. Before the partitioning wipe, read the existing wifi_creds.json
off the target (if present) into /tmp/ac-wifi-preserve.*.json.
After mount, merge preset + preserved with Python one-liner:
dedupe by SSID, preserved entries override presets for the same
SSID (so user-saved passwords survive a re-flash). Both partitions
(ACBOOT + ACEFI) get the same merged file.

If the caller stages their own wifi_creds.json at ${SRC_DIR}/wifi_creds.json
(e.g. /tmp/ac-os-pull/wifi_creds.json) that file wins as source-of-truth
and neither preset nor preserved merge is applied.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+60 -2
+60 -2
fedac/native/scripts/flash-mac.sh
··· 86 86 [ -z "${USER_HANDLE}${USER_SUB}${USER_EMAIL}" ] && \ 87 87 log "No ~/.ac-token (run \`ac-login\` first to bake credentials in)" 88 88 89 + # --- preserve existing wifi_creds.json from target USB before we wipe it --- 90 + # Linux `ac-os flash` does this via ac_media_merge_wifi_creds: read the 91 + # previously-flashed USB for user-added networks, then merge with the 92 + # built-in preset list. We mirror that behavior so a reflash keeps your 93 + # kitchen/studio/friend's-apartment wifi without re-typing. 94 + PRESERVE_WIFI="" 95 + for mnt in /Volumes/ACBOOT /Volumes/ACEFI; do 96 + if [ -f "${mnt}/wifi_creds.json" ]; then 97 + # Copy while readable — the partition is about to be unmounted. 98 + PRESERVE_WIFI="/tmp/ac-wifi-preserve.$$.json" 99 + cp "${mnt}/wifi_creds.json" "${PRESERVE_WIFI}" 2>/dev/null && \ 100 + log "Preserving wifi_creds.json from ${mnt}" && break 101 + fi 102 + done 103 + trap "rm -f '${PRESERVE_WIFI}' 2>/dev/null" EXIT 104 + 105 + # --- hardcoded preset networks (kept in sync with media-layout.sh + src/wifi.c) --- 106 + WIFI_PRESETS_JSON='[ 107 + {"ssid":"aesthetic.computer","pass":"aesthetic.computer"}, 108 + {"ssid":"ATT2AWTpcr","pass":"t84q%7%g2h8u"}, 109 + {"ssid":"GettyLink","pass":""}, 110 + {"ssid":"Tondo_Guest","pass":"California"} 111 + ]' 112 + 89 113 INFO=$(diskutil info "${USB_DEV}" 2>/dev/null) || die "diskutil info failed for ${USB_DEV}" 90 114 echo "${INFO}" | grep -q "Removable Media:.*Removable\|Device Location:.*External" \ 91 115 || die "${USB_DEV} is not removable/external. Aborting." ··· 173 197 cp "${INITRAMFS}" "${M1}/initramfs.cpio.gz" 174 198 printf '{"handle":"%s","piece":"notepat","sub":"%s","email":"%s"}\n' \ 175 199 "${USER_HANDLE}" "${USER_SUB}" "${USER_EMAIL}" | tee "${M1}/config.json" >/dev/null 176 - [ -f "${SRC_DIR}/wifi_creds.json" ] && cp "${SRC_DIR}/wifi_creds.json" "${M1}/wifi_creds.json" 200 + 201 + # Build merged wifi_creds.json (presets + preserved + optional override) 202 + # once, reuse for both partitions. 203 + WIFI_MERGED="/tmp/ac-wifi-merged.$$.json" 204 + if [ -f "${SRC_DIR}/wifi_creds.json" ]; then 205 + # Caller-provided override wins as source-of-truth. 206 + cp "${SRC_DIR}/wifi_creds.json" "${WIFI_MERGED}" 207 + log "Using wifi_creds.json from ${SRC_DIR}" 208 + else 209 + # Presets + preserved merge. Python dedupes by SSID keeping the LAST 210 + # occurrence's password (preserved > presets, so user-saved networks 211 + # override the hardcoded entries if both reference the same SSID). 212 + if [ -n "${PRESERVE_WIFI}" ] && [ -f "${PRESERVE_WIFI}" ]; then 213 + python3 -c " 214 + import json, sys 215 + presets = json.loads(sys.argv[1]) 216 + preserved = json.load(open(sys.argv[2])) 217 + order = [] 218 + merged = {} 219 + for entry in (presets + preserved): 220 + if not isinstance(entry, dict): continue 221 + ssid = entry.get('ssid') 222 + if not ssid: continue 223 + if ssid not in merged: order.append(ssid) 224 + merged[ssid] = {'ssid': ssid, 'pass': str(entry.get('pass', ''))} 225 + with open(sys.argv[3], 'w') as f: 226 + json.dump([merged[s] for s in order], f, indent=2) 227 + " "${WIFI_PRESETS_JSON}" "${PRESERVE_WIFI}" "${WIFI_MERGED}" \ 228 + && log "Merged $(python3 -c 'import json,sys; print(len(json.load(open(sys.argv[1]))))' "${WIFI_MERGED}") wifi networks (presets + preserved)" 229 + else 230 + printf '%s\n' "${WIFI_PRESETS_JSON}" > "${WIFI_MERGED}" 231 + log "Wrote 4 preset wifi networks (no previous USB to preserve from)" 232 + fi 233 + fi 234 + cp "${WIFI_MERGED}" "${M1}/wifi_creds.json" 177 235 178 236 # --- layout ACEFI (systemd-boot universal) --- 179 237 log "Writing ACEFI (splash → systemd-boot → kernel)…" ··· 194 252 EOF 195 253 printf '{"handle":"%s","piece":"notepat","sub":"%s","email":"%s"}\n' \ 196 254 "${USER_HANDLE}" "${USER_SUB}" "${USER_EMAIL}" | tee "${M2}/config.json" >/dev/null 197 - [ -f "${SRC_DIR}/wifi_creds.json" ] && cp "${SRC_DIR}/wifi_creds.json" "${M2}/wifi_creds.json" 255 + [ -f "${WIFI_MERGED}" ] && cp "${WIFI_MERGED}" "${M2}/wifi_creds.json" 198 256 199 257 # --- verify (sha256 round-trip on every kernel + initramfs copy) --- 200 258 log "Verifying integrity…"