PrawnOS-nonfree/resources/BuildResources/initramfs-init

57 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/busybox sh
echo In PrawnOS Init
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}
#uncomment for debugging
2019-09-26 20:10:47 +02:00
exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
# 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
umount /dev
# exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
#swith to the new rootfs
exec switch_root /newroot /sbin/init ${CMDLINE}