]>
Commit | Line | Data |
---|---|---|
89a12446 DM |
1 | #!/bin/bash |
2 | ||
3 | trap "err_reboot" ERR | |
4 | ||
5 | parse_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 | ||
17 | debugsh() { | |
16ff00ec | 18 | /bin/bash |
89a12446 DM |
19 | } |
20 | ||
21 | real_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 | ||
46 | err_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 | ||
52 | echo "Starting Proxmox installation" | |
53 | ||
54 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin | |
55 | ||
194d737a TL |
56 | # ensure udev isn't snippy and ignores our request |
57 | export SYSTEMD_IGNORE_CHROOT=1 | |
58 | ||
89a12446 | 59 | mount -n -t proc proc /proc |
89a12446 | 60 | mount -n -t sysfs sysfs /sys |
f238dd03 TL |
61 | if [ -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 | 64 | fi |
8d7ddbde | 65 | mount -n -t tmpfs tmpfs /run |
89a12446 DM |
66 | |
67 | parse_cmdline | |
68 | ||
69 | # always load most common input drivers | |
000f289d TL |
70 | modprobe -q psmouse || true |
71 | modprobe -q sermouse || true | |
72 | modprobe -q usbhid || true | |
89a12446 DM |
73 | |
74 | # load device mapper - used by lilo | |
000f289d | 75 | modprobe -q dm_mod || true |
89a12446 DM |
76 | |
77 | echo "Installing additional hardware drivers" | |
dbe9a0c9 | 78 | export RUNLEVEL=S |
89a12446 DM |
79 | export PREVLEVEL=N |
80 | /etc/init.d/udev start | |
81 | ||
3119bdeb TL |
82 | mkdir -p /dev/shm |
83 | mount -t tmpfs tmpfs /dev/shm | |
84 | ||
4569e022 TL |
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 | ||
11a42156 | 89 | if [ $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 |
94 | fi |
95 | ||
dbe9a0c9 | 96 | # set the hostname |
89a12446 DM |
97 | hostname proxmox |
98 | ||
89a12446 | 99 | # try to get ip config with dhcp |
01e402f0 FG |
100 | echo -n "Attempting to get DHCP leases... " |
101 | dhclient -v | |
89a12446 DM |
102 | echo "done" |
103 | ||
150291b3 TL |
104 | echo -n "Starting chrony for opportunistic time-sync... " |
105 | chronyd || echo "starting chrony failed" | |
106 | ||
909936b5 SI |
107 | echo "Starting a root shell on tty3." |
108 | setsid /sbin/agetty -a root --noclear tty3 & | |
109 | ||
89a12446 DM |
110 | xinit -- -dpi 96 >/dev/tty2 2>&1 |
111 | ||
b0c4afcc DM |
112 | # just to be sure everything is on disk |
113 | sync | |
114 | ||
89a12446 | 115 | if [ $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 |
118 | fi |
119 | ||
120 | echo "Installation done, rebooting... " | |
d13c1966 TL |
121 | |
122 | killall5 -15 | |
123 | ||
89a12446 DM |
124 | real_reboot |
125 | ||
126 | # never reached | |
127 | exit 0 |