Add pika-refind-btrfs-hooks/usr/share/booster/hooks-early/01_pika_live.sh
This commit is contained in:
parent
f5afd1274c
commit
53dbced29e
@ -0,0 +1,77 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Mount the proc kernel temp mount
|
||||
busybox mount -n -t proc proc /proc
|
||||
|
||||
# Check if bootloader wants the hook to be executed
|
||||
|
||||
BOOT_PARAM="$(busybox grep -o 'boot=[^ ]*' /proc/cmdline | busybox awk -F= '{print $2}')"
|
||||
|
||||
if [[ $BOOT_PARAM != "live" ]]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VTOY_ISO_NAME_PARAM="$(busybox grep -o 'VTOY_ISO_NAME=[^ ]*' /proc/cmdline | busybox awk -F= '{print $2}')"
|
||||
|
||||
busybox echo '[PikaOS Booster Live Hook]: boot=live detected in kernel cmdline, running LiveISO hooks...'
|
||||
|
||||
### Create mounting dirs
|
||||
busybox echo '[PikaOS Booster Live Hook]: Creating mountpoints...'
|
||||
busybox mkdir -p /mnt/medium /mnt/filesystem /mnt/overlay /booster.root
|
||||
|
||||
# Try finding Appended partition among standard partition blocks.
|
||||
busybox echo '[PikaOS Booster Live Hook]: Searching for Live medium...'
|
||||
LIVE_MEDIA="$(busybox blkid | busybox grep "PikaOS 4" | busybox grep "iso9660" | busybox head -n1 | busybox awk -F: '{print $1}')"
|
||||
|
||||
if [ -z "$LIVE_MEDIA" ]
|
||||
then
|
||||
# Try getting appended partition from Ventoy ISO Partition
|
||||
busybox echo '[PikaOS Booster Live Hook]: Live medium could not be found among standard blocks.'
|
||||
busybox echo '[PikaOS Booster Live Hook]: Attempting Ventoy mapping hook.'
|
||||
# Get Ventoy ISO Partition ID
|
||||
VENTOY_DEVICE="$(busybox blkid | busybox grep "Ventoy" | busybox head -n1 | busybox awk -F: '{print $1}')"
|
||||
# Keep retrying 10 times incase usb_storage has yet to pick up
|
||||
while [ -z "$VENTOY_DEVICE" ]
|
||||
do
|
||||
busybox echo '[PikaOS Booster Live Hook]: Ventoy Device not found retrying...'
|
||||
VENTOY_DEVICE="$(busybox blkid | busybox grep "Ventoy" | busybox head -n1 | busybox awk -F: '{print $1}')"
|
||||
((c++)) && ((c==10)) && break
|
||||
sleep 5
|
||||
done
|
||||
# Get filesystem if iso was found
|
||||
if [ ! -z "$VENTOY_DEVICE" ]
|
||||
then
|
||||
busybox echo "[PikaOS Booster Live Hook]: Ventoy device found as $VENTOY_DEVICE !"
|
||||
busybox mkdir -p /mnt/ventoy
|
||||
busybox mount -o ro "$VENTOY_DEVICE" /mnt/ventoy
|
||||
### Mount live medium
|
||||
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium...'
|
||||
busybox mount -o ro,loop /mnt/ventoy/$VTOY_ISO_NAME_PARAM /mnt/medium
|
||||
else
|
||||
busybox echo '[PikaOS Booster Live Hook]: Error: Live medium could not be found!'
|
||||
exit 32
|
||||
fi
|
||||
else
|
||||
busybox echo "[PikaOS Booster Live Hook]: Live medium found on $LIVE_MEDIA !"
|
||||
### Mount live medium
|
||||
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium...'
|
||||
busybox mount -o ro $LIVE_MEDIA /mnt/medium
|
||||
fi
|
||||
|
||||
### Create loop from squashfs
|
||||
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium squashfs image...'
|
||||
busybox mount -o loop,ro /mnt/medium/live/filesystem.squashfs /mnt/filesystem
|
||||
|
||||
### Mount tmpfs on ram
|
||||
busybox echo '[PikaOS Booster Live Hook]: Creating Ramfs...'
|
||||
busybox mount -t tmpfs -o mode=1777 overlay_tmpfs /mnt/overlay
|
||||
|
||||
### Create overlay dirs
|
||||
busybox mkdir -p /mnt/overlay/upper /mnt/overlay/work
|
||||
|
||||
### Create merged overlay
|
||||
busybox echo '[PikaOS Booster Live Hook]: Creating writable overlay Rootfs on ramfs...'
|
||||
busybox mount -t overlay overlay -o lowerdir=/mnt/filesystem:/mnt/medium,upperdir=/mnt/overlay/upper,workdir=/mnt/overlay/work /booster.root
|
Loading…
x
Reference in New Issue
Block a user