2019-09-18 03:50:27 +02:00
|
|
|
#!/bin/busybox sh
|
|
|
|
|
|
|
|
|
2019-09-21 06:50:08 +02:00
|
|
|
echo In PrawnOS Init
|
|
|
|
|
2019-09-18 03:50:27 +02:00
|
|
|
cmdline() {
|
|
|
|
local value
|
|
|
|
value=" $(cat /proc/cmdline) "
|
|
|
|
value="${value##* ${1}=}"
|
|
|
|
value="${value%% *}"
|
|
|
|
[ "${value}" != "" ] && echo "${value}"
|
|
|
|
}
|
|
|
|
|
|
|
|
rootpartuuid() {
|
|
|
|
local value
|
|
|
|
value=$1
|
|
|
|
value="${value%/*}"
|
|
|
|
value="${value#*=}"
|
|
|
|
[ "${value}" != "" ] && echo "${value}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# mount the bare necesities
|
|
|
|
mount -n -t proc proc /proc
|
|
|
|
mount -n -t sysfs sysfs /sys
|
|
|
|
mount -n -t devtmpfs devtmpfs /dev
|
|
|
|
|
|
|
|
# get the root device, so we can find the boot partiton
|
|
|
|
UNPARSED=$(cmdline root)
|
|
|
|
ROOT_PARTUUID=$(rootpartuuid $UNPARSED)
|
|
|
|
echo ${ROOT_PARTUUID}
|
|
|
|
BLKID=$(/bin/blkid | grep $ROOT_PARTUUID )
|
|
|
|
echo ${BLKID}
|
|
|
|
#If its an mmcblk device, the partiton will p1. If it is a usb device, the partiton will just be 1
|
|
|
|
#Just want everything before the 1: so this will work
|
|
|
|
ROOT_DEV="${BLKID%1:*}"
|
|
|
|
|
|
|
|
echo ${ROOT_DEV}
|
|
|
|
|
2019-09-21 06:50:08 +02:00
|
|
|
#uncomment for debugging
|
2019-09-26 20:34:59 +02:00
|
|
|
# exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
|
2019-09-18 03:50:27 +02:00
|
|
|
|
|
|
|
# we use this to change what cmdline options get passed into
|
|
|
|
# the next boot stage, aka to enable root encryption
|
|
|
|
CMDLINE='cat /proc/cmdline'
|
|
|
|
|
|
|
|
# mount new root
|
|
|
|
[ -d /newroot ] || mkdir -p /newroot
|
|
|
|
mount ${ROOT_DEV}3 /newroot
|
|
|
|
|
|
|
|
umount /sys
|
|
|
|
umount /proc
|
2019-09-21 06:50:08 +02:00
|
|
|
|
|
|
|
# exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
|
2019-09-18 03:50:27 +02:00
|
|
|
|
|
|
|
#swith to the new rootfs
|
2019-09-21 06:50:08 +02:00
|
|
|
exec switch_root /newroot /sbin/init ${CMDLINE}
|