Switch first boot setup to console wizard
This commit is contained in:
parent
686691fff7
commit
33f60af92a
@ -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
|
||||
|
||||
@ -50,6 +50,7 @@ autoinstall:
|
||||
- curl
|
||||
- wget
|
||||
- python3
|
||||
- whiptail
|
||||
- avahi-daemon
|
||||
- openssh-server
|
||||
|
||||
@ -63,25 +64,22 @@ autoinstall:
|
||||
- echo "cezen ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/cezen
|
||||
- chmod 440 /target/etc/sudoers.d/cezen
|
||||
|
||||
# Replace the installer-generated network config with the final static
|
||||
# Cezen network so the installed system always has the expected route.
|
||||
# Replace the installer-generated network config with a simple DHCP target
|
||||
# config. The console wizard can later switch this to static if desired.
|
||||
- rm -f /target/etc/netplan/50-cloud-init.yaml /target/etc/netplan/00-installer-config.yaml || true
|
||||
- |
|
||||
cat > /target/etc/netplan/99-cezen-static.yaml << 'EOF'
|
||||
cat > /target/etc/netplan/99-cezen-dhcp.yaml << 'EOF'
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
ens18:
|
||||
dhcp4: false
|
||||
addresses:
|
||||
- 172.16.10.181/23
|
||||
routes:
|
||||
- to: default
|
||||
via: 172.16.10.1
|
||||
nameservers:
|
||||
addresses:
|
||||
- 8.8.8.8
|
||||
- 1.1.1.1
|
||||
any-en:
|
||||
dhcp4: true
|
||||
match:
|
||||
name: "en*"
|
||||
any-eth:
|
||||
dhcp4: true
|
||||
match:
|
||||
name: "eth*"
|
||||
EOF
|
||||
|
||||
# Disable the installer media APT source so post-install apt uses network
|
||||
@ -93,29 +91,37 @@ autoinstall:
|
||||
- mkdir -p /target/opt/aipackage
|
||||
- cp -a /cdrom/cezen-aipackage/. /target/opt/aipackage/ || git clone https://cgit.cezentech.com/jinojose/aipackage.git /target/opt/aipackage
|
||||
|
||||
# Deploy the web setup server
|
||||
# Deploy the console setup wizard
|
||||
- mkdir -p /target/opt/cezen
|
||||
- cp /target/opt/aipackage/autoinstall/websetup/server.py /target/opt/cezen/websetup.py
|
||||
- chmod +x /target/opt/cezen/websetup.py
|
||||
- cp /target/opt/aipackage/autoinstall/firstboot-setup.sh /target/opt/cezen/firstboot-setup.sh
|
||||
- chmod +x /target/opt/cezen/firstboot-setup.sh
|
||||
|
||||
# Set hostname to cezenai so it's reachable as cezenai.local via mDNS
|
||||
- echo "cezenai" > /target/etc/hostname
|
||||
- sed -i 's/aiserver/cezenai/g' /target/etc/hosts || true
|
||||
|
||||
# Create cezen-setup web UI systemd service
|
||||
# Create cezen-setup console UI systemd service on tty1
|
||||
- |
|
||||
cat > /target/etc/systemd/system/cezen-setup.service << 'EOF'
|
||||
[Unit]
|
||||
Description=Cezen AI Suite — Web Setup UI
|
||||
Description=Cezen AI Suite — Console Setup Wizard
|
||||
After=network-online.target avahi-daemon.service
|
||||
Wants=network-online.target
|
||||
Before=getty@tty1.service
|
||||
Conflicts=getty@tty1.service
|
||||
ConditionPathExists=!/opt/cezen/.setup-done
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/python3 /opt/cezen/websetup.py
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
ExecStart=/opt/cezen/firstboot-setup.sh
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=tty
|
||||
TTYPath=/dev/tty1
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
TTYVTDisallocate=yes
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Loading…
Reference in New Issue
Block a user