]> git.proxmox.com Git - pve-installer.git/blob - unconfigured.sh
mount efivarfs to ensure we can read bigger variables
[pve-installer.git] / unconfigured.sh
1 #!/bin/bash
2
3 trap "err_reboot" ERR
4
5 parse_cmdline() {
6 root=
7 proxdebug=0
8 for par in $(cat /proc/cmdline); do
9 case $par in
10 root=*)
11 root=${par#root=}
12 ;;
13 proxdebug)
14 proxdebug=1
15 ;;
16 esac
17 done;
18 }
19
20 debugsh() {
21 /bin/bash
22 }
23
24 real_reboot() {
25
26 trap - ERR
27
28 /etc/init.d/networking stop
29
30 # stop udev (release file handles)
31 /etc/init.d/udev stop
32
33 echo -n "Deactivating swap..."
34 swap=$(grep /dev /proc/swaps);
35 if [ -n "$swap" ]; then
36 set $swap
37 swapoff $1
38 fi
39 echo "done."
40
41 umount -l -n /target >/dev/null 2>&1
42 umount -l -n /dev
43 umount -l -n /run
44 umount -l -n /sys
45 umount -l -n /proc
46
47 exit 0
48 }
49
50 err_reboot() {
51
52 echo "\nInstallation aborted - unable to continue (type exit or CTRL-D to reboot)"
53 debugsh
54 real_reboot
55 }
56
57 echo "Starting Proxmox installation"
58
59 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
60
61 # ensure udev isn't snippy and ignores our request
62 export SYSTEMD_IGNORE_CHROOT=1
63
64 mount -n -t proc proc /proc
65 mount -n -t sysfs sysfs /sys
66 if [ -d /sys/firmware/efi ]; then
67 echo "EFI boot mode detected, mounting efivars filesystem"
68 mount -nt efivarfs none /sys/firmware/efi/efivars
69 fi
70 mount -n -t tmpfs tmpfs /run
71
72 parse_cmdline
73
74 # always load most common input drivers
75 modprobe -q psmouse || /bin/true
76 modprobe -q sermouse || /bin/true
77 modprobe -q usbhid || /bin/true
78
79 # load device mapper - used by lilo
80 modprobe -q dm_mod || /bin/true
81
82 echo "Installing additional hardware drivers"
83 export RUNLEVEL=S
84 export PREVLEVEL=N
85 /etc/init.d/udev start
86
87 mkdir -p /dev/shm
88 mount -t tmpfs tmpfs /dev/shm
89
90 if [ $proxdebug -ne 0 ]; then
91 echo "Dropping in debug shell inside chroot before starting installation"
92 echo "type exit or CTRL-D to start installation wizard"
93 debugsh
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 xinit -- -dpi 96 >/dev/tty2 2>&1
105
106 # just to be sure everything is on disk
107 sync
108
109 if [ $proxdebug -ne 0 ]; then
110 echo "Debugging mode (type exit or CTRL-D to reboot)"
111 debugsh
112 fi
113
114 echo "Installation done, rebooting... "
115 #mdadm -S /dev/md0 >/dev/tty2 2>&1
116 kill $(pidof dhclient) 2>&1 > /dev/null
117 real_reboot
118
119 # never reached
120 exit 0