]> git.proxmox.com Git - pve-installer.git/blame - unconfigured.sh
unconfigured: adapt some log messages
[pve-installer.git] / unconfigured.sh
CommitLineData
89a12446
DM
1#!/bin/bash
2
3trap "err_reboot" ERR
4
5parse_cmdline() {
89a12446 6 proxdebug=0
9e5787e5 7 # shellcheck disable=SC2013 # per word splitting is wanted here
dbe9a0c9 8 for par in $(cat /proc/cmdline); do
9e5787e5
TL
9 case $par in
10 proxdebug)
11 proxdebug=1
12 ;;
13 esac
89a12446
DM
14 done;
15}
16
17debugsh() {
16ff00ec 18 /bin/bash
89a12446
DM
19}
20
21real_reboot() {
dbe9a0c9 22 trap - ERR
89a12446 23
dbe9a0c9 24 /etc/init.d/networking stop
89a12446
DM
25
26 # stop udev (release file handles)
27 /etc/init.d/udev stop
28
29 echo -n "Deactivating swap..."
20d20ee3 30 swap=$(awk '/^\/dev\// { print $1 }' /proc/swaps);
89a12446 31 if [ -n "$swap" ]; then
20d20ee3 32 swapoff "$swap"
89a12446
DM
33 fi
34 echo "done."
35
89a12446 36 umount -l -n /target >/dev/null 2>&1
37a88382 37 umount -l -n /dev
8d7ddbde 38 umount -l -n /run
dea730ea 39 [ -d /sys/firmware/efi/efivars ] && umount -l -n /sys/firmware/efi/efivars
89a12446 40 umount -l -n /sys
e89d1aef 41 umount -l -n /proc
89a12446
DM
42
43 exit 0
44}
45
46err_reboot() {
4fb3a9c6 47 printf "\nInstallation aborted - unable to continue (type exit or CTRL-D to reboot)\n"
2e3fe722 48 debugsh || true
89a12446
DM
49 real_reboot
50}
51
52echo "Starting Proxmox installation"
53
54PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
55
194d737a
TL
56# ensure udev isn't snippy and ignores our request
57export SYSTEMD_IGNORE_CHROOT=1
58
89a12446 59mount -n -t proc proc /proc
89a12446 60mount -n -t sysfs sysfs /sys
f238dd03
TL
61if [ -d /sys/firmware/efi ]; then
62 echo "EFI boot mode detected, mounting efivars filesystem"
dea730ea 63 mount -n -t efivarfs efivarfs /sys/firmware/efi/efivars
f238dd03 64fi
8d7ddbde 65mount -n -t tmpfs tmpfs /run
89a12446
DM
66
67parse_cmdline
68
69# always load most common input drivers
000f289d
TL
70modprobe -q psmouse || true
71modprobe -q sermouse || true
72modprobe -q usbhid || true
89a12446
DM
73
74# load device mapper - used by lilo
000f289d 75modprobe -q dm_mod || true
89a12446
DM
76
77echo "Installing additional hardware drivers"
dbe9a0c9 78export RUNLEVEL=S
89a12446
DM
79export PREVLEVEL=N
80/etc/init.d/udev start
81
3119bdeb
TL
82mkdir -p /dev/shm
83mount -t tmpfs tmpfs /dev/shm
84
4569e022
TL
85# allow pseudo terminals for debuggin in X
86mkdir -p /dev/pts
87mount -vt devpts devpts /dev/pts -o gid=5,mode=620
88
11a42156 89if [ $proxdebug -ne 0 ]; then
aa0fe276 90 /sbin/agetty -o '-p -- \\u' --noclear tty9 &
4fb3a9c6
TL
91 echo "Dropping in debug shell before starting installation"
92 echo "type exit or CTRL-D to continue and start the installation wizard"
2e3fe722 93 debugsh || true
11a42156
TL
94fi
95
dbe9a0c9 96# set the hostname
89a12446
DM
97hostname proxmox
98
89a12446 99# try to get ip config with dhcp
01e402f0
FG
100echo -n "Attempting to get DHCP leases... "
101dhclient -v
89a12446
DM
102echo "done"
103
150291b3
TL
104echo -n "Starting chrony for opportunistic time-sync... "
105chronyd || echo "starting chrony failed"
106
909936b5
SI
107echo "Starting a root shell on tty3."
108setsid /sbin/agetty -a root --noclear tty3 &
109
89a12446
DM
110xinit -- -dpi 96 >/dev/tty2 2>&1
111
b0c4afcc
DM
112# just to be sure everything is on disk
113sync
114
89a12446 115if [ $proxdebug -ne 0 ]; then
000f289d 116 echo "Debug shell after installation exited (type exit or CTRL-D to reboot)"
2e3fe722 117 debugsh || true
89a12446
DM
118fi
119
120echo "Installation done, rebooting... "
d13c1966
TL
121
122killall5 -15
123
89a12446
DM
124real_reboot
125
126# never reached
127exit 0