5 # NOTE: we nowadays get exec'd by the initrd's PID 1, so we're the new PID 1
9 # shellcheck disable=SC2013 # per word splitting is wanted here
10 for par
in $
(cat /proc
/cmdline
); do
24 iso_dev
=$
(awk '/ iso9660 / {print $1}' /proc
/mounts
)
26 for try
in 5 4 3 2 1; do
28 if umount
-v -a --types iso9660
; then
32 echo "unmount failed - trying again in 5 seconds"
37 if [ -n "$iso_dev" ]; then
38 eject
"$iso_dev" || true
# cannot really work currently, don't care
43 echo "rebooting - please remove the ISO boot media"
47 echo "trigger reset system request"
48 # we do not expect the reboot above to fail, so rather to avoid kpanic when pid 1 exits
49 echo b
> /proc
/sysrq-trigger
56 if [[ -x /etc
/init.d
/networking
]]; then
57 /etc
/init.d
/networking stop
60 # stop udev (release file handles)
63 swap
=$
(awk '/^\/dev\// { print $1 }' /proc
/swaps
);
64 if [ -n "$swap" ]; then
65 echo -n "Deactivating swap..."
73 umount
-l -n /target
>/dev
/null
2>&1
77 [ -d /sys
/firmware
/efi
/efivars
] && umount
-l -n /sys
/firmware
/efi
/efivars
79 # do not unmount proc and sys for now, at least /proc is still required to trigger the actual
80 # reboot, and both are virtual FS only anyway
82 echo "Terminate all remaining processes"
83 kill -s TERM
-1 # TERMinate all but current init (our self) PID 1
85 echo "Kill any remaining processes"
86 kill -s KILL
-1 # KILL all but current init (our self) PID 1
91 exit 0 # shouldn't be reached, kernel will panic in that case
95 printf "\nInstallation aborted - unable to continue (type exit or CTRL-D to reboot)\n"
100 # NOTE: dbus must be launched before this, else iwd cannot work
101 # FIXME: very crude, still needs to actually copy over any iwd config to target
104 for iface
in /sys
/class
/net
/*; do
105 if [ -d "$iface/wireless" ]; then
109 if [ -z $wireless_found ]; then
113 if [ -x /usr
/libexec
/iwd
]; then
114 echo "wireless device(s) found, starting iwd; use 'iwctl' to manage connections (experimental)"
117 echo "wireless device found but iwd not available, ignoring"
121 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
:/usr
/X11R
6/bin
123 echo "Starting Proxmox installation"
125 # ensure udev doesn't ignores our request; FIXME: not required anymore, as we use switch_root now
126 export SYSTEMD_IGNORE_CHROOT
=1
128 mount
-n -t proc proc
/proc
129 mount
-n -t sysfs sysfs
/sys
130 if [ -d /sys
/firmware
/efi
]; then
131 echo "EFI boot mode detected, mounting efivars filesystem"
132 mount
-n -t efivarfs efivarfs
/sys
/firmware
/efi
/efivars
134 mount
-n -t tmpfs tmpfs
/run
138 # always load most common input drivers
139 modprobe
-q psmouse || true
140 modprobe
-q sermouse || true
141 modprobe
-q usbhid || true
143 # load device mapper - used by lilo
144 modprobe
-q dm_mod || true
146 echo "Installing additional hardware drivers"
149 /etc
/init.d
/udev start
152 mount
-t tmpfs tmpfs
/dev
/shm
154 # allow pseudo terminals for debuggin in X
156 mount
-vt devpts devpts
/dev
/pts
-o gid
=5,mode
=620
158 # shellcheck disable=SC2207
159 console_dim
=($
(IFS
=' ' stty size
)) # [height, width]
161 if (("${console_dim[0]}" > 100)) && (("${console_dim[1]}" > 400)); then
162 # heuristic only, high resolution can still mean normal/low DPI if it's a really big screen
163 # FIXME: use `edid-decode` as it can contain physical dimensions to calculate actual dpi?
164 echo "detected huge console, setting bigger font/dpi"
167 setfont
/usr
/share
/consolefonts
/Uni2-Terminus32x16.psf.gz
173 if command -v dbus-daemon
; then
174 echo "starting D-Bus daemon"
176 dbus-daemon
--system --syslog-only
178 if [ $proxdebug -ne 0 ]; then # FIXME: better intergration, e.g., use iwgtk?
179 handle_wireless
# no-op if not wireless dev is found
183 # we use a trimmed down debootstrap so make busybox tools available to compensate that
184 busybox
--install -s || true
186 setupcon ||
echo "setupcon failed, TUI rendering might be garbled - $?"
188 if [ $proxdebug -ne 0 ]; then
189 /sbin
/agetty
-o '-p -- \\u' --noclear tty9
&
190 printf "\nDropping in debug shell before starting installation\n"
191 echo "type 'exit' or press CTRL + D to continue and start the installation wizard"
195 # try to get ip config with dhcp
196 echo -n "Attempting to get DHCP leases... "
200 echo "Starting chrony for opportunistic time-sync... "
201 chronyd ||
echo "starting chrony failed ($?)"
203 echo "Starting a root shell on tty3."
204 setsid
/sbin
/agetty
-a root
--noclear tty3
&
206 echo "Starting the installer GUI - see tty2 (CTRL+ALT+F2) for any errors..."
207 xinit
-- -dpi "$DPI" >/dev
/tty2
2>&1
209 # just to be sure everything is on disk
212 if [ $proxdebug -ne 0 ]; then
213 printf "\nDebug shell after installation exited (type exit or CTRL-D to reboot)\n"
217 echo "Installation done, rebooting... "