Switch first boot setup to console wizard

This commit is contained in:
Jino Jose committed 2026-06-25 09:15:15 +05:30
1 parent 686691fff7
commit 33f60af92a
2 files changed
+52 -27

No files matched your search

+24 -5
View File
@@ -10,6 +10,13 @@ AIPACKAGE_DIR="/opt/aipackage"
LOG_FILE="/var/log/cezen-setup.log"
exec > >(tee -a "$LOG_FILE") 2>&1
detect_iface() {
ip route show default 2>/dev/null | awk '/default/ {print $5; exit}'
}
IFACE="$(detect_iface)"
IFACE="${IFACE:-$(ip -o link show | awk -F': ' '$2 !~ /lo|docker|br-|veth/ {print $2; exit}')}"
# ── Colors / terminal setup ────────────────────────────────
export NEWT_COLORS='
root=,black
@@ -49,9 +56,7 @@ NET_MODE=$(whiptail --title "$TITLE" \
3>&1 1>&2 2>&3)
if [ "$NET_MODE" = "Static" ]; then
# Detect first ethernet interface
IFACE=$(ip -o link show | awk -F': ' '$2 !~ /lo|docker|br-|veth/ {print $2; exit}')
rm -f /etc/netplan/99-cezen-dhcp.yaml || true
IP_ADDR=$(whiptail --title "$TITLE" \
--inputbox "\nEnter static IP address:\n(Example: 192.168.1.100)" \
@@ -100,12 +105,22 @@ EOF
fi
else
# DHCP — just confirm it's working
# DHCP — persist it explicitly and confirm it's working
rm -f /etc/netplan/99-cezen-static.yaml || true
cat > /etc/netplan/99-cezen-dhcp.yaml << EOF
network:
version: 2
ethernets:
${IFACE}:
dhcp4: true
EOF
netplan apply 2>/dev/null || true
sleep 2
MY_IP=$(hostname -I | awk '{print $1}')
if [ -n "$MY_IP" ]; then
whiptail --title "$TITLE" \
--msgbox "\nDHCP configured successfully!\n\nServer IP: ${MY_IP}\n\nYou can set a static IP later via:\n sudo nano /etc/netplan/50-cloud-init.yaml" \
--msgbox "\nDHCP configured successfully!\n\nServer IP: ${MY_IP}\n\nYou can switch to a static IP later by editing:\n /etc/netplan/99-cezen-dhcp.yaml" \
$H $W
else
whiptail --title "$TITLE" \
@@ -190,3 +205,7 @@ touch /opt/cezen/.setup-done
# Run the installer
bash "$AIPACKAGE_DIR/install.sh" --tier="$TIER"
whiptail --title "$TITLE" \
--msgbox "\nInstaller command finished.\n\nFor detailed logs, run:\n sudo journalctl -u cezen-phase2.service -f\n sudo tail -f /var/log/cezen-install.log" \
$H $W