feat(console): add netconf command for quick network setup
Interactive script: lists interfaces, DHCP or static IP config. Shown as hint in tty1 welcome message. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,6 @@ if [ -z "${SSH_CONNECTION:-}" ] \
|
|||||||
done
|
done
|
||||||
unset _ips _ip
|
unset _ips _ip
|
||||||
echo ""
|
echo ""
|
||||||
echo " Local desktop starts automatically on display :0"
|
echo " Network setup: netconf"
|
||||||
echo " Kernel logs: Alt+F2 | Extra shell: Alt+F3"
|
echo " Kernel logs: Alt+F2 | Extra shell: Alt+F3"
|
||||||
fi
|
fi
|
||||||
|
|||||||
50
iso/overlay/usr/local/bin/netconf
Executable file
50
iso/overlay/usr/local/bin/netconf
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Quick network configurator for the local console.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# List interfaces (exclude lo)
|
||||||
|
IFACES=$(ip -o link show | awk -F': ' '$2 != "lo" {print $2}' | cut -d@ -f1)
|
||||||
|
|
||||||
|
echo "Interfaces:"
|
||||||
|
i=1
|
||||||
|
for iface in $IFACES; do
|
||||||
|
ip=$(ip -4 addr show "$iface" 2>/dev/null | awk '/inet /{print $2}' | head -1)
|
||||||
|
echo " $i) $iface ${ip:-no IP}"
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
printf "Interface name [or Enter to pick first]: "
|
||||||
|
read IFACE
|
||||||
|
if [ -z "$IFACE" ]; then
|
||||||
|
IFACE=$(echo "$IFACES" | head -1)
|
||||||
|
fi
|
||||||
|
echo "Selected: $IFACE"
|
||||||
|
echo ""
|
||||||
|
echo " 1) DHCP"
|
||||||
|
echo " 2) Static"
|
||||||
|
printf "Mode [1]: "
|
||||||
|
read MODE
|
||||||
|
MODE=${MODE:-1}
|
||||||
|
|
||||||
|
if [ "$MODE" = "1" ]; then
|
||||||
|
echo "Running DHCP on $IFACE..."
|
||||||
|
dhclient -v "$IFACE"
|
||||||
|
else
|
||||||
|
printf "IP address (e.g. 192.168.1.100/24): "
|
||||||
|
read ADDR
|
||||||
|
printf "Gateway (e.g. 192.168.1.1): "
|
||||||
|
read GW
|
||||||
|
printf "DNS [8.8.8.8]: "
|
||||||
|
read DNS
|
||||||
|
DNS=${DNS:-8.8.8.8}
|
||||||
|
|
||||||
|
ip addr flush dev "$IFACE"
|
||||||
|
ip addr add "$ADDR" dev "$IFACE"
|
||||||
|
ip link set "$IFACE" up
|
||||||
|
ip route add default via "$GW"
|
||||||
|
echo "nameserver $DNS" > /etc/resolv.conf
|
||||||
|
echo "Done."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
ip -4 addr show "$IFACE"
|
||||||
Reference in New Issue
Block a user