- dev-vm.sh: rewrite for macOS (bsdtar ISO extraction, Homebrew mkfs.ext4 detection, direct kernel boot, TCG acceleration, port 8080 forwarding) - inject-kubesolo.sh: add CA certificates bundle from builder so containerd can verify TLS when pulling from registries (Docker Hub, etc.) - 50-network.sh: add DNS fallback (10.0.2.3 + 8.8.8.8) when DHCP client doesn't populate /etc/resolv.conf - 90-kubesolo.sh: serve kubeconfig via HTTP on port 8080 for reliable retrieval from host, add 127.0.0.1 and 10.0.2.15 to API server SANs - portainer.go: add headless Service to Edge Agent manifest (required for agent peer discovery DNS lookup) - 10-parse-cmdline.sh + init.sh: add kubesolo.edge_id/edge_key boot params - 20-persistent-mount.sh: auto-format unformatted data disks on first boot - hack/fix-portainer-service.sh: helper to patch running cluster Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
2.3 KiB
Bash
Executable File
74 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# 50-network.sh — Configure networking
|
|
# Priority: cloud-init (stage 45) > saved config > DHCP fallback
|
|
|
|
# If cloud-init already configured networking, skip this stage
|
|
if [ "$CLOUDINIT_APPLIED" = "1" ]; then
|
|
log "Network already configured by cloud-init — skipping"
|
|
return 0
|
|
fi
|
|
|
|
# Check for saved network config (from previous boot or cloud-init)
|
|
if [ -f "$DATA_MOUNT/network/interfaces.sh" ]; then
|
|
log "Applying saved network configuration"
|
|
. "$DATA_MOUNT/network/interfaces.sh"
|
|
return 0
|
|
fi
|
|
|
|
# Fallback: DHCP on first non-loopback interface
|
|
log "Configuring network via DHCP"
|
|
|
|
# Bring up loopback (use ifconfig for BusyBox compatibility)
|
|
ifconfig lo 127.0.0.1 netmask 255.0.0.0 up 2>/dev/null || \
|
|
{ ip link set lo up 2>/dev/null && ip addr add 127.0.0.1/8 dev lo 2>/dev/null; } || true
|
|
|
|
# Find first ethernet interface
|
|
ETH_DEV=""
|
|
for iface in /sys/class/net/*; do
|
|
iface="$(basename "$iface")"
|
|
case "$iface" in
|
|
lo|docker*|veth*|br*|cni*|dummy*|tunl*|sit*) continue ;;
|
|
esac
|
|
ETH_DEV="$iface"
|
|
break
|
|
done
|
|
|
|
if [ -z "$ETH_DEV" ]; then
|
|
log_err "No network interface found"
|
|
return 1
|
|
fi
|
|
|
|
log "Using interface: $ETH_DEV"
|
|
ifconfig "$ETH_DEV" up 2>/dev/null || ip link set "$ETH_DEV" up 2>/dev/null || true
|
|
|
|
# Run DHCP client (BusyBox udhcpc)
|
|
if command -v udhcpc >/dev/null 2>&1; then
|
|
udhcpc -i "$ETH_DEV" -s /usr/share/udhcpc/default.script \
|
|
-t 10 -T 3 -A 5 -b -q 2>/dev/null || {
|
|
log_err "DHCP failed on $ETH_DEV"
|
|
return 1
|
|
}
|
|
elif command -v dhcpcd >/dev/null 2>&1; then
|
|
dhcpcd "$ETH_DEV" || {
|
|
log_err "DHCP failed on $ETH_DEV"
|
|
return 1
|
|
}
|
|
else
|
|
log_err "No DHCP client available (need udhcpc or dhcpcd)"
|
|
return 1
|
|
fi
|
|
|
|
# Ensure /etc/resolv.conf has valid DNS (udhcpc should have written it,
|
|
# but verify and add fallbacks if missing)
|
|
if [ ! -s /etc/resolv.conf ]; then
|
|
log_warn "/etc/resolv.conf is empty — adding fallback DNS"
|
|
echo "nameserver 10.0.2.3" > /etc/resolv.conf
|
|
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
|
|
elif ! grep -q nameserver /etc/resolv.conf 2>/dev/null; then
|
|
log_warn "No nameserver in /etc/resolv.conf — adding fallback DNS"
|
|
echo "nameserver 10.0.2.3" >> /etc/resolv.conf
|
|
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
|
|
fi
|
|
|
|
log_ok "Network configured on $ETH_DEV (DNS: $(grep nameserver /etc/resolv.conf 2>/dev/null | head -1))"
|