forked from finn/tinyboard
fix(setup-network): update all netplan files containing access-points, not just the first one
This commit is contained in:
@@ -195,14 +195,16 @@ case "$NET_OPT" in
|
||||
warn "No IP assigned yet — DHCP may still be in progress."
|
||||
fi
|
||||
|
||||
NETPLAN_FILE=$(ls /etc/netplan/*.yaml 2>/dev/null | head -1)
|
||||
if [ -n "$NETPLAN_FILE" ] && grep -q "access-points" "$NETPLAN_FILE" 2>/dev/null; then
|
||||
warn "Updating netplan config with new WiFi credentials..."
|
||||
NETPLAN_BACKUP_DIR="/root/.config/tinyboard/netplan-backups"
|
||||
mkdir -p "$NETPLAN_BACKUP_DIR"
|
||||
|
||||
while IFS= read -r -d '' NETPLAN_FILE; do
|
||||
if ! grep -q "access-points" "$NETPLAN_FILE" 2>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
BACKUP_FILE="$NETPLAN_BACKUP_DIR/$(basename "${NETPLAN_FILE}").$(date +%Y%m%d%H%M%S)"
|
||||
cp "$NETPLAN_FILE" "$BACKUP_FILE"
|
||||
info "Netplan config backed up to $BACKUP_FILE"
|
||||
info "Backed up: $NETPLAN_FILE → $BACKUP_FILE"
|
||||
|
||||
python3 - "$NETPLAN_FILE" "$NEW_SSID" "$NEW_PASS" <<'PYEOF'
|
||||
import sys, re
|
||||
@@ -216,8 +218,10 @@ txt = re.sub(
|
||||
)
|
||||
open(path, "w").write(txt)
|
||||
PYEOF
|
||||
info "Netplan config updated. Changes will persist on next boot."
|
||||
fi
|
||||
info "Updated: $NETPLAN_FILE"
|
||||
done < <(find /etc/netplan -maxdepth 1 -name '*.yaml' -print0 2>/dev/null)
|
||||
|
||||
info "All netplan configs updated. Changes will persist on next boot."
|
||||
|
||||
info "Connected to '${NEW_SSID}' successfully."
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user