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