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