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
32 echo "unmount failed -trying again in 5 seconds"
37 if [ -n "$iso_dev" ]; then
41 echo "rebooting - please remove the ISO boot media"
43 echo b
> /proc
/sysrq-trigger
50 /etc
/init.d
/networking stop
52 # stop udev (release file handles)
55 echo -n "Deactivating swap..."
56 swap
=$
(awk '/^\/dev\// { print $1 }' /proc
/swaps
);
57 if [ -n "$swap" ]; then
62 umount
-l -n /target
>/dev
/null
2>&1
67 [ -d /sys
/firmware
/efi
/efivars
] && umount
-l -n /sys
/firmware
/efi
/efivars
69 # do not unmount proc and sys for now, at least /proc is still required to trigger the actual
70 # reboot, and both are virtual FS only anyway
72 echo "Terminate all remaining processes"
73 kill -s TERM
-1 # TERMinate all but current init (our self) PID 1
75 echo "Kill any remaining processes"
76 kill -s KILL
-1 # KILL all but current init (our self) PID 1
81 exit 0 # shouldn't be reached, kernel will panic in that case
85 printf "\nInstallation aborted - unable to continue (type exit or CTRL-D to reboot)\n"
90 # NOTE: dbus must be launched before this, else iwd cannot work
91 # FIXME: very crude, still needs to actually copy over any iwd config to target
94 for iface
in /sys
/class
/net
/*; do
95 if [ -d "$iface/wireless" ]; then
99 if [ -z $wireless_found ]; then
103 if [ -x /usr
/libexec
/iwd
]; then
104 echo "wireless device(s) found, starting iwd; use 'iwctl' to manage connections (experimental)"
107 echo "wireless device found but iwd not available, ignoring"
111 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
:/usr
/X11R
6/bin
113 echo "Starting Proxmox installation"
115 # ensure udev doesn't ignores our request; FIXME: not required anymore, as we use switch_root now
116 export SYSTEMD_IGNORE_CHROOT
=1
118 mount
-n -t proc proc
/proc
119 mount
-n -t sysfs sysfs
/sys
120 if [ -d /sys
/firmware
/efi
]; then
121 echo "EFI boot mode detected, mounting efivars filesystem"
122 mount
-n -t efivarfs efivarfs
/sys
/firmware
/efi
/efivars
124 mount
-n -t tmpfs tmpfs
/run
128 # always load most common input drivers
129 modprobe
-q psmouse || true
130 modprobe
-q sermouse || true
131 modprobe
-q usbhid || true
133 # load device mapper - used by lilo
134 modprobe
-q dm_mod || true
136 echo "Installing additional hardware drivers"
139 /etc
/init.d
/udev start
142 mount
-t tmpfs tmpfs
/dev
/shm
144 # allow pseudo terminals for debuggin in X
146 mount
-vt devpts devpts
/dev
/pts
-o gid
=5,mode
=620
148 # shellcheck disable=SC2207
149 console_dim
=($
(IFS
=' ' stty size
)) # [height, width]
151 if (("${console_dim[0]}" > 100)) && (("${console_dim[1]}" > 400)); then
152 # heuristic only, high resolution can still mean normal/low DPI if it's a really big screen
153 # FIXME: use `edid-decode` as it can contain physical dimensions to calculate actual dpi?
154 echo "detected huge console, setting bigger font/dpi"
157 setfont
/usr
/share
/consolefonts
/Uni2-Terminus32x16.psf.gz
163 if command -v dbus-daemon
; then
164 echo "starting D-Bus daemon"
166 dbus-daemon
--system --syslog-only
168 if [ $proxdebug -ne 0 ]; then # FIXME: better intergration, e.g., use iwgtk?
169 handle_wireless
# no-op if not wireless dev is found
173 # we use a trimmed down debootstrap so make busybox tools available to compensate that
174 busybox
--install -s || true
176 if [ $proxdebug -ne 0 ]; then
177 /sbin
/agetty
-o '-p -- \\u' --noclear tty9
&
178 printf "\nDropping in debug shell before starting installation\n"
179 echo "type exit or CTRL-D to continue and start the installation wizard"
183 # try to get ip config with dhcp
184 echo -n "Attempting to get DHCP leases... "
188 echo -n "Starting chrony for opportunistic time-sync... "
189 chronyd ||
echo "starting chrony failed ($?)"
191 echo "Starting a root shell on tty3."
192 setsid
/sbin
/agetty
-a root
--noclear tty3
&
194 xinit
-- -dpi "$DPI" >/dev
/tty2
2>&1
196 # just to be sure everything is on disk
199 if [ $proxdebug -ne 0 ]; then
200 printf "\nDebug shell after installation exited (type exit or CTRL-D to reboot)\n"
204 echo "Installation done, rebooting... "