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."
|
warn "No IP assigned yet — DHCP may still be in progress."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NETPLAN_FILE=$(ls /etc/netplan/*.yaml 2>/dev/null | head -1)
|
NETPLAN_BACKUP_DIR="/root/.config/tinyboard/netplan-backups"
|
||||||
if [ -n "$NETPLAN_FILE" ] && grep -q "access-points" "$NETPLAN_FILE" 2>/dev/null; then
|
mkdir -p "$NETPLAN_BACKUP_DIR"
|
||||||
warn "Updating netplan config with new WiFi credentials..."
|
|
||||||
NETPLAN_BACKUP_DIR="/root/.config/tinyboard/netplan-backups"
|
while IFS= read -r -d '' NETPLAN_FILE; do
|
||||||
mkdir -p "$NETPLAN_BACKUP_DIR"
|
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)"
|
BACKUP_FILE="$NETPLAN_BACKUP_DIR/$(basename "${NETPLAN_FILE}").$(date +%Y%m%d%H%M%S)"
|
||||||
cp "$NETPLAN_FILE" "$BACKUP_FILE"
|
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'
|
python3 - "$NETPLAN_FILE" "$NEW_SSID" "$NEW_PASS" <<'PYEOF'
|
||||||
import sys, re
|
import sys, re
|
||||||
@@ -216,8 +218,10 @@ txt = re.sub(
|
|||||||
)
|
)
|
||||||
open(path, "w").write(txt)
|
open(path, "w").write(txt)
|
||||||
PYEOF
|
PYEOF
|
||||||
info "Netplan config updated. Changes will persist on next boot."
|
info "Updated: $NETPLAN_FILE"
|
||||||
fi
|
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."
|
info "Connected to '${NEW_SSID}' successfully."
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user