2020-01-27 19:09:58 +05:30
|
|
|
#!/sbin/busybox sh
|
2020-01-05 23:31:39 +05:30
|
|
|
|
|
|
|
# debugging
|
|
|
|
set -x
|
|
|
|
|
|
|
|
# install busybox
|
2020-01-27 19:09:58 +05:30
|
|
|
/sbin/busybox --install -s
|
2020-01-05 23:31:39 +05:30
|
|
|
|
|
|
|
panic() { echo "bruh moment :(" && sh; }
|
|
|
|
|
|
|
|
# silence is golden
|
|
|
|
#echo 0 > /proc/sys/kernel/printk
|
|
|
|
|
|
|
|
# check config
|
|
|
|
[ -f /config ] && . /config || panic
|
|
|
|
|
|
|
|
# mount pseudofs's
|
|
|
|
mount -t proc none /proc
|
|
|
|
mount -t sysfs none /sys
|
|
|
|
mount -t devtmpfs none /dev
|
|
|
|
|
2020-01-25 16:57:02 +05:30
|
|
|
# TODO implement busybox mdev/mdevd
|
2020-01-05 23:31:39 +05:30
|
|
|
# setup mdev
|
2020-01-25 16:57:02 +05:30
|
|
|
#echo /sbin/mdev >/proc/sys/kernel/hotplug
|
2020-01-05 23:31:39 +05:30
|
|
|
#mdev -s
|
|
|
|
|
2020-01-19 02:31:21 +05:30
|
|
|
# setup udev
|
|
|
|
udevd --daemon
|
|
|
|
udevadm trigger --action=add --type=subsystems
|
|
|
|
udevadm trigger --action=add --type=devices
|
|
|
|
udevadm settle
|
|
|
|
|
2020-01-05 23:31:39 +05:30
|
|
|
# TODO parse /proc/cmdline
|
|
|
|
|
2020-01-25 16:57:02 +05:30
|
|
|
# unlock cryptsetup container
|
|
|
|
[ "$use_luks" = 1 ] && {
|
|
|
|
luks_root="$(findfs $luks_root)"
|
|
|
|
# TODO improve mapper name ( crypttab or config option )
|
|
|
|
cryptsetup $luks_args luksOpen "$luks_root" luks_root || panic
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:31:39 +05:30
|
|
|
# load drivers
|
2020-01-19 02:31:21 +05:30
|
|
|
#modprobe -a $drivers
|
2020-01-05 23:31:39 +05:30
|
|
|
|
2020-01-19 02:31:21 +05:30
|
|
|
# merge mount flags
|
2020-01-25 16:57:02 +05:30
|
|
|
[ -n "$root_args" ] && mount_args="$root_args"
|
|
|
|
[ -n "$root_type" ] && mount_args="$mount_args -t $root_type"
|
2020-01-05 23:31:39 +05:30
|
|
|
|
|
|
|
# mount rootfs
|
2020-01-25 16:57:02 +05:30
|
|
|
mount $mount_args "$root" /mnt/root || panic
|
2020-01-05 23:31:39 +05:30
|
|
|
|
|
|
|
# clean up
|
2020-01-19 02:31:21 +05:30
|
|
|
udevadm control --exit
|
2020-01-25 16:57:02 +05:30
|
|
|
umount /dev /sys /proc
|
2020-01-05 23:31:39 +05:30
|
|
|
|
|
|
|
# boot system
|
|
|
|
echo SUCCESS
|
2020-01-25 16:57:02 +05:30
|
|
|
exec switch_root /mnt/root /sbin/init
|