Add quiet mode

This commit is contained in:
Ward from fusion-voyager-3 2024-12-17 20:30:41 +03:00
parent d3367f6b68
commit f2f680e37b
2 changed files with 65 additions and 17 deletions

View File

@ -1,4 +1,4 @@
pika-live-booster-hooks (1.0-101pika1) pika; urgency=medium
pika-live-booster-hooks (1.0-101pika2) pika; urgency=medium
* Initial release.

View File

@ -14,64 +14,112 @@ then
exit 0
fi
# Check if quiet is used
if [[ "$(busybox cat /proc/cmdline)" =~ (^|[[:space:]])quiet($|[[:space:]]) ]]; then
QUIET_MODE=true
else
QUIET_MODE=false
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...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: boot=live detected in kernel cmdline, running LiveISO hooks...'
fi
### Create mounting dirs
busybox echo '[PikaOS Booster Live Hook]: Creating mountpoints...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Creating mountpoints...'
fi
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...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Searching for Live medium...'
fi
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.'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Live medium could not be found among standard blocks.'
fi
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Attempting Ventoy mapping hook.'
fi
# 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...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Ventoy Device not found retrying...'
fi
VENTOY_DEVICE="$(busybox blkid | busybox grep "Ventoy" | busybox head -n1 | busybox awk -F: '{print $1}')"
((c++)) && ((c==10)) && break
sleep 5
busybox 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 !"
if [ "$QUIET_MODE" = false ]
then
busybox echo "[PikaOS Booster Live Hook]: Ventoy device found as $VENTOY_DEVICE !"
fi
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...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium...'
fi
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!'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Error: Live medium could not be found!'
fi
exit 32
fi
else
busybox echo "[PikaOS Booster Live Hook]: Live medium found on $LIVE_MEDIA !"
if [ "$QUIET_MODE" = false ]
then
busybox echo "[PikaOS Booster Live Hook]: Live medium found on $LIVE_MEDIA !"
fi
### Mount live medium
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium...'
fi
busybox mount -o ro $LIVE_MEDIA /mnt/medium
fi
### Create loop from squashfs
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium squashfs image...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Mounting Live medium squashfs image...'
fi
busybox mount -o loop,ro /mnt/medium/live/filesystem.squashfs /mnt/filesystem
### Mount tmpfs on ram
busybox echo '[PikaOS Booster Live Hook]: Creating Ramfs...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Creating Ramfs...'
fi
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...'
if [ "$QUIET_MODE" = false ]
then
busybox echo '[PikaOS Booster Live Hook]: Creating writable overlay Rootfs on ramfs...'
fi
busybox mount -t overlay overlay -o lowerdir=/mnt/filesystem:/mnt/medium,upperdir=/mnt/overlay/upper,workdir=/mnt/overlay/work /booster.root