#!/bin/sh

# Copyright (C) 2013-2025 Marcin Krol <hawk@tld-linux.org>
# All Rights Reserved

export PATH="/sbin:/bin"
/bin/busybox --install -s
mount -n -t proc none /proc
fs_size=$(sed -nr '/rootfssize=[[:digit:]]+[GM]/{s/.*rootfssize=//; s/[[:space:]]+.*//; p;}' /proc/cmdline 2>/dev/null)
if [ -z "${fs_size}" ]; then
  fs_size="1G"
fi
umount /proc
mount -n -t tmpfs -o size="${fs_size}" none /system
echo "[1;37mDecompressing CRI system[0m"
mv -f /lib /system/
cd /system
tar Jxf /cri.tar.xz
rm -f /cri.tar.xz
echo "[1;37mInitializing[0m"
exec switch_root /system /init
