Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/busybox sh
- # Install busybox
- /bin/busybox --install -s
- # Mount the /proc and /sys filesystems.
- mount -t proc none /proc
- mount -t sysfs none /sys
- mount -t devtmpfs none /dev
- # turn off noise so we can see password prompt
- echo "1 1 1 1" > /proc/sys/kernel/printk
- # load display driver
- modprobe disp
- cmdline() {
- local value
- value=" $(cat /proc/cmdline) "
- value="${value##* $1=}"
- value="${value%% *}"
- [ "$value" != "" ] && echo "$value"
- }
- m_echo() {
- echo $1
- echo $1 > /dev/tty1
- }
- run_on_tty1() {
- setsid sh -c "exec $1 <>/dev/tty1 >&0 2>&1"
- }
- realboot() {
- m_echo "Unlocking rootfs: $1"
- run_on_tty1 "cryptsetup open --allow-discards $1 cryptroot"
- if [ ! -e /dev/mapper/cryptroot ]; then
- m_echo "Something went wrong: /dev/mapper/cryptroot does not exist"
- else
- m_echo "Encrypted root unlocked, mounting and booting..."
- mkdir -p /mnt/root
- mount -o rw /dev/mapper/cryptroot /mnt/root
- if [ -x /mnt/root/sbin/init -o -h /mnt/root/sbin/init ]; then
- # Cleanup.
- umount /proc
- umount /sys
- umount /dev
- # Boot the real system.
- exec switch_root /mnt/root /sbin/init
- else
- umount /mnt/root
- fi
- fi
- }
- runshell() {
- m_echo "Dropping to a shell."
- m_echo
- setsid cttyhack /bin/sh
- }
- find_parition_by_value() {
- echo $(blkid | tr -d '"' | grep "$1" | cut -d ':' -f 1 | head -n 1)
- }
- boot() {
- m_echo "Kernel params: `cat /proc/cmdline`"
- local i=5
- local kernel_root_param=$(cmdline root)
- while [ "$i" -ge 1 ]; do
- m_echo "Waiting for root system $kernel_root_param, countdown : $i"
- local root=$(find_parition_by_value $kernel_root_param)
- if [ -e "$root" ]; then
- realboot $root;
- fi;
- i=$(( $i - 1 ));
- sleep 5;
- done;
- # Default rootfs - sd partition 2
- realboot /dev/mmcblk0p2;
- run_on_tty1 "sh"
- runshell
- }
- boot;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement