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"
|
LOG_FILE="/var/log/cezen-setup.log"
|
||||||
exec > >(tee -a "$LOG_FILE") 2>&1
|
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 ────────────────────────────────
|
# ── Colors / terminal setup ────────────────────────────────
|
||||||
export NEWT_COLORS='
|
export NEWT_COLORS='
|
||||||
root=,black
|
root=,black
|
||||||
@ -49,9 +56,7 @@ NET_MODE=$(whiptail --title "$TITLE" \
|
|||||||
3>&1 1>&2 2>&3)
|
3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
if [ "$NET_MODE" = "Static" ]; then
|
if [ "$NET_MODE" = "Static" ]; then
|
||||||
|
rm -f /etc/netplan/99-cezen-dhcp.yaml || true
|
||||||
# Detect first ethernet interface
|
|
||||||
IFACE=$(ip -o link show | awk -F': ' '$2 !~ /lo|docker|br-|veth/ {print $2; exit}')
|
|
||||||
|
|
||||||
IP_ADDR=$(whiptail --title "$TITLE" \
|
IP_ADDR=$(whiptail --title "$TITLE" \
|
||||||
--inputbox "\nEnter static IP address:\n(Example: 192.168.1.100)" \
|
--inputbox "\nEnter static IP address:\n(Example: 192.168.1.100)" \
|
||||||
@ -100,12 +105,22 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
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
|
sleep 2
|
||||||
MY_IP=$(hostname -I | awk '{print $1}')
|
MY_IP=$(hostname -I | awk '{print $1}')
|
||||||
if [ -n "$MY_IP" ]; then
|
if [ -n "$MY_IP" ]; then
|
||||||
whiptail --title "$TITLE" \
|
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
|
$H $W
|
||||||
else
|
else
|
||||||
whiptail --title "$TITLE" \
|
whiptail --title "$TITLE" \
|
||||||
@ -190,3 +205,7 @@ touch /opt/cezen/.setup-done
|
|||||||
|
|
||||||
# Run the installer
|
# Run the installer
|
||||||
bash "$AIPACKAGE_DIR/install.sh" --tier="$TIER"
|
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
|
- curl
|
||||||
- wget
|
- wget
|
||||||
- python3
|
- python3
|
||||||
|
- whiptail
|
||||||
- avahi-daemon
|
- avahi-daemon
|
||||||
- openssh-server
|
- openssh-server
|
||||||
|
|
||||||
@ -63,25 +64,22 @@ autoinstall:
|
|||||||
- echo "cezen ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/cezen
|
- echo "cezen ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/cezen
|
||||||
- chmod 440 /target/etc/sudoers.d/cezen
|
- chmod 440 /target/etc/sudoers.d/cezen
|
||||||
|
|
||||||
# Replace the installer-generated network config with the final static
|
# Replace the installer-generated network config with a simple DHCP target
|
||||||
# Cezen network so the installed system always has the expected route.
|
# 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
|
- 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:
|
network:
|
||||||
version: 2
|
version: 2
|
||||||
ethernets:
|
ethernets:
|
||||||
ens18:
|
any-en:
|
||||||
dhcp4: false
|
dhcp4: true
|
||||||
addresses:
|
match:
|
||||||
- 172.16.10.181/23
|
name: "en*"
|
||||||
routes:
|
any-eth:
|
||||||
- to: default
|
dhcp4: true
|
||||||
via: 172.16.10.1
|
match:
|
||||||
nameservers:
|
name: "eth*"
|
||||||
addresses:
|
|
||||||
- 8.8.8.8
|
|
||||||
- 1.1.1.1
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Disable the installer media APT source so post-install apt uses network
|
# Disable the installer media APT source so post-install apt uses network
|
||||||
@ -93,29 +91,37 @@ autoinstall:
|
|||||||
- mkdir -p /target/opt/aipackage
|
- 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
|
- 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
|
- mkdir -p /target/opt/cezen
|
||||||
- cp /target/opt/aipackage/autoinstall/websetup/server.py /target/opt/cezen/websetup.py
|
- cp /target/opt/aipackage/autoinstall/firstboot-setup.sh /target/opt/cezen/firstboot-setup.sh
|
||||||
- chmod +x /target/opt/cezen/websetup.py
|
- chmod +x /target/opt/cezen/firstboot-setup.sh
|
||||||
|
|
||||||
# Set hostname to cezenai so it's reachable as cezenai.local via mDNS
|
# Set hostname to cezenai so it's reachable as cezenai.local via mDNS
|
||||||
- echo "cezenai" > /target/etc/hostname
|
- echo "cezenai" > /target/etc/hostname
|
||||||
- sed -i 's/aiserver/cezenai/g' /target/etc/hosts || true
|
- 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'
|
cat > /target/etc/systemd/system/cezen-setup.service << 'EOF'
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Cezen AI Suite — Web Setup UI
|
Description=Cezen AI Suite — Console Setup Wizard
|
||||||
After=network-online.target avahi-daemon.service
|
After=network-online.target avahi-daemon.service
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
|
Before=getty@tty1.service
|
||||||
|
Conflicts=getty@tty1.service
|
||||||
ConditionPathExists=!/opt/cezen/.setup-done
|
ConditionPathExists=!/opt/cezen/.setup-done
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/bin/python3 /opt/cezen/websetup.py
|
ExecStart=/opt/cezen/firstboot-setup.sh
|
||||||
Restart=on-failure
|
StandardInput=tty
|
||||||
RestartSec=5
|
StandardOutput=tty
|
||||||
|
StandardError=tty
|
||||||
|
TTYPath=/dev/tty1
|
||||||
|
TTYReset=yes
|
||||||
|
TTYVHangup=yes
|
||||||
|
TTYVTDisallocate=yes
|
||||||
|
Restart=no
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user