]> git.proxmox.com Git - pve-installer.git/blobdiff - unconfigured.sh
bump version to 8.1.10
[pve-installer.git] / unconfigured.sh
index 5460821fdb78cb24e15c264062743e1d5fbcedc2..cf7de834df8f678b701f4ee1951b5c8f0655301a 100755 (executable)
@@ -6,11 +6,19 @@ trap "err_reboot" ERR
 
 parse_cmdline() {
     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=1
+                proxdebug=1
+            ;;
+            proxtui)
+                proxtui=1
+            ;;
+            console=ttyS*)
+                serial=1
             ;;
         esac
     done;
@@ -24,22 +32,28 @@ eject_and_reboot() {
     iso_dev=$(awk '/ iso9660 / {print $1}' /proc/mounts)
 
     for try in 5 4 3 2 1; do
-        echo "unmounting all"
-        if umount -a; then
+        echo "unmounting ISO"
+        if umount -v -a --types iso9660; then
             break
         fi
         if test -n $try; then
-            echo "unmount failed -trying again in 5 seconds"
+            echo "unmount failed - trying again in 5 seconds"
             sleep 5
         fi
     done
 
     if [ -n "$iso_dev" ]; then
-        eject "$iso_dev"
+        eject "$iso_dev" || true # cannot really work currently, don't care
     fi
 
+    umount -l -n /dev
+
     echo "rebooting - please remove the ISO boot media"
     sleep 3
+    reboot -nf
+    sleep 5
+    echo "trigger reset system request"
+    # we do not expect the reboot above to fail, so rather to avoid kpanic when pid 1 exits
     echo b > /proc/sysrq-trigger
     sleep 100
 }
@@ -47,30 +61,38 @@ eject_and_reboot() {
 real_reboot() {
     trap - ERR
 
-    /etc/init.d/networking stop
+    if [[ -x /etc/init.d/networking ]]; then
+        /etc/init.d/networking stop
+    fi
 
     # stop udev (release file handles)
     /etc/init.d/udev stop
 
-    echo -n "Deactivating swap..."
     swap=$(awk '/^\/dev\// { print $1 }' /proc/swaps);
     if [ -n "$swap" ]; then
-       swapoff "$swap"
+        echo -n "Deactivating swap..."
+        swapoff "$swap"
+        echo "done."
     fi
-    echo "done."
+
+    # just to be sure
+    sync
 
     umount -l -n /target >/dev/null 2>&1
     umount -l -n /dev/pts
     umount -l -n /dev/shm
-    umount -l -n /dev
     umount -l -n /run
     [ -d /sys/firmware/efi/efivars ] && umount -l -n /sys/firmware/efi/efivars
 
     # do not unmount proc and sys for now, at least /proc is still required to trigger the actual
     # reboot, and both are virtual FS only anyway
 
-    kill -s KILL -1 # kill all but current init (our self) PID 1
-    sleep 1
+    echo "Terminate all remaining processes"
+    kill -s TERM -1 # TERMinate all but current init (our self) PID 1
+    sleep 2
+    echo "Kill any remaining processes"
+    kill -s KILL -1 # KILL all but current init (our self) PID 1
+    sleep 0.5
 
     eject_and_reboot
 
@@ -118,6 +140,7 @@ if [ -d /sys/firmware/efi ]; then
     mount -n -t efivarfs efivarfs /sys/firmware/efi/efivars
 fi
 mount -n -t tmpfs tmpfs /run
+mkdir -p /run/proxmox-installer
 
 parse_cmdline
 
@@ -166,10 +189,15 @@ if command -v dbus-daemon; then
     fi
 fi
 
+# we use a trimmed down debootstrap so make busybox tools available to compensate that
+busybox --install -s || true
+
+setupcon || echo "setupcon failed, TUI rendering might be garbled - $?"
+
 if [ $proxdebug -ne 0 ]; then
     /sbin/agetty -o '-p -- \\u' --noclear tty9 &
     printf "\nDropping in debug shell before starting installation\n"
-    echo "type exit or CTRL-D to continue and start the installation wizard"
+    echo "type 'exit' or press CTRL + D to continue and start the installation wizard"
     debugsh || true
 fi
 
@@ -178,13 +206,26 @@ echo -n "Attempting to get DHCP leases... "
 dhclient -v
 echo "done"
 
-echo -n "Starting chrony for opportunistic time-sync... "
+echo "Starting chrony for opportunistic time-sync... "
 chronyd || echo "starting chrony failed ($?)"
 
 echo "Starting a root shell on tty3."
 setsid /sbin/agetty -a root --noclear tty3 &
 
-xinit -- -dpi "$DPI" >/dev/tty2 2>&1
+/usr/bin/proxmox-low-level-installer dump-env
+
+if [ $proxtui -ne 0 ]; then
+    if [ "$serial" -ne 0 ]; then
+        echo "Setting terminal size to 80x24 for serial install"
+        stty columns 80 rows 25
+    fi
+
+    echo "Starting the TUI installer"
+    /usr/bin/proxmox-tui-installer 2>/dev/tty2
+else
+    echo "Starting the installer GUI - see tty2 (CTRL+ALT+F2) for any errors..."
+    xinit -- -dpi "$DPI" -s 0 >/dev/tty2 2>&1
+fi
 
 # just to be sure everything is on disk
 sync