]> git.proxmox.com Git - pve-installer.git/blobdiff - unconfigured.sh
install module: getters: correctly use plural in error messages
[pve-installer.git] / unconfigured.sh
index ba9b9e33722df2d674eca9e171c0b8b322b6b0cc..a39e6ad774baf8a4949c4aa8e47531dd8fd8c01a 100755 (executable)
@@ -5,17 +5,25 @@ trap "err_reboot" ERR
 # NOTE: we nowadays get exec'd by the initrd's PID 1, so we're the new PID 1
 
 parse_cmdline() {
+    start_auto_installer=0
     proxdebug=0
     proxtui=0
+    serial=0
     # shellcheck disable=SC2013 # per word splitting is wanted here
     for par in $(cat /proc/cmdline); do
         case $par in
-            proxdebug)
+            proxdebug|proxmox-debug)
                 proxdebug=1
             ;;
-            proxtui)
+            proxtui|proxmox-tui-mode)
                 proxtui=1
             ;;
+            proxauto|proxmox-start-auto-installer)
+                start_auto_installer=1
+            ;;
+            console=ttyS*)
+                serial=1
+            ;;
         esac
     done;
 }
@@ -95,6 +103,8 @@ real_reboot() {
     exit 0 # shouldn't be reached, kernel will panic in that case
 }
 
+# reachable through the ERR trap
+# shellcheck disable=SC2317
 err_reboot() {
     printf "\nInstallation aborted - unable to continue (type exit or CTRL-D to reboot)\n"
     debugsh || true
@@ -190,6 +200,11 @@ busybox --install -s || true
 
 setupcon || echo "setupcon failed, TUI rendering might be garbled - $?"
 
+if [ "$serial" -ne 0 ]; then
+    echo "Setting terminal size to 80x24 for serial install"
+    stty columns 80 rows 24
+fi
+
 if [ $proxdebug -ne 0 ]; then
     /sbin/agetty -o '-p -- \\u' --noclear tty9 &
     printf "\nDropping in debug shell before starting installation\n"
@@ -197,6 +212,16 @@ if [ $proxdebug -ne 0 ]; then
     debugsh || true
 fi
 
+# add custom DHCP options for auto installer
+if [ $start_auto_installer -ne 0 ]; then
+    echo "Preparing DHCP as potential source to get location of automatic-installation answer file"
+    cat >> /etc/dhcp/dhclient.conf <<EOF
+option proxmox-auto-installer-manifest-url code 250 = text;
+option proxmox-auto-installer-cert-fingerprint code 251 = text;
+also request proxmox-auto-installer-manifest-url, proxmox-auto-installer-cert-fingerprint;
+EOF
+fi
+
 # try to get ip config with dhcp
 echo -n "Attempting to get DHCP leases... "
 dhclient -v
@@ -213,9 +238,25 @@ setsid /sbin/agetty -a root --noclear tty3 &
 if [ $proxtui -ne 0 ]; then
     echo "Starting the TUI installer"
     /usr/bin/proxmox-tui-installer 2>/dev/tty2
+elif [ $start_auto_installer -ne 0 ]; then
+    echo "Caching device info from udev"
+    /usr/bin/proxmox-low-level-installer dump-udev
+
+    if [ -f /cdrom/auto-installer-mode.toml ]; then
+        echo "Fetching answers for automatic installation"
+        /usr/bin/proxmox-fetch-answer >/run/automatic-installer-answers
+    else
+        printf "\nAutomatic installation selected but no config for fetching the answer file found!\n"
+        echo "Starting debug shell, to fetch the answer file manually use:"
+        echo "  proxmox-fetch-answer MODE >/run/automatic-installer-answers"
+        echo "and enter 'exit' or press 'CTRL' + 'D' when finished."
+        debugsh || true
+    fi
+    echo "Starting automatic installation"
+    /usr/bin/proxmox-auto-installer </run/automatic-installer-answers
 else
     echo "Starting the installer GUI - see tty2 (CTRL+ALT+F2) for any errors..."
-    xinit -- -dpi "$DPI" >/dev/tty2 2>&1
+    xinit -- -dpi "$DPI" -s 0 >/dev/tty2 2>&1
 fi
 
 # just to be sure everything is on disk
@@ -233,4 +274,5 @@ killall5 -15
 real_reboot
 
 # never reached
+# shellcheck disable=SC2317
 exit 0