diff options
| author | Linux User <emmett@vmi2195005.contaboserver.net> | 2025-04-11 06:52:47 +0000 |
|---|---|---|
| committer | Linux User <emmett@vmi2195005.contaboserver.net> | 2025-04-11 06:52:47 +0000 |
| commit | 45060d13faf603ba1e5f6a636b826fed85114a8a (patch) | |
| tree | 07cb15402a7a72156267070cec32a3465d98f679 /utils/mkiso.d/init | |
| parent | cd09bb7d98628514649b1ea2cec6dff948d5ca04 (diff) | |
| download | alicelinux-clang.tar.gz alicelinux-clang.zip | |
added utilsclang
Diffstat (limited to 'utils/mkiso.d/init')
| -rw-r--r-- | utils/mkiso.d/init | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/utils/mkiso.d/init b/utils/mkiso.d/init new file mode 100644 index 00000000..05356e39 --- /dev/null +++ b/utils/mkiso.d/init @@ -0,0 +1,96 @@ +#!/bin/busybox sh + +NEWROOT=/.newroot +INITRAMFS=/run/initramfs +MEDIA=$INITRAMFS/media +LOWER=$INITRAMFS/lower +UPPER=$INITRAMFS/upper +WORK=$INITRAMFS/work +SFSIMAGE=$MEDIA/boot/rootfs.sfs + +/bin/busybox --install -s /bin + +clear + +mkdir -p /proc /sys /run /dev +mount -t proc proc /proc +mount -t sysfs sysfs /sys +mount -t tmpfs run /run +mount -t devtmpfs dev /dev + +mkdir -p $LOWER $MEDIA $UPPER $WORK $NEWROOT + +exec >/dev/console </dev/console 2>&1 + +PRINTK="`cat /proc/sys/kernel/printk`" +echo "0" > /proc/sys/kernel/printk + +# mdev +mkdir -p /etc +echo '$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' > /etc/mdev.conf +mdev -df & pid_mdev=$! + +# load kernel modules, twice +find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a >/dev/null 2>&1 +find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a >/dev/null 2>&1 + +# load kernel modules required for live iso +for m in loop cdrom isofs overlay squashfs usb-storage loop fuse exfat; do + modprobe $m >/dev/null 2>&1 +done + +echo "Please wait..." + +# figure out media +if [ -f /proc/sys/dev/cdrom/info ]; then + CDROM=$(grep name /proc/sys/dev/cdrom/info | awk -F : '{print $2}' | awk '{print $1}') +fi + +while [ "$wait" != 10 ]; do + BLOCK=$(grep -E '[vsh]d' /proc/partitions | awk '{print $4}') + for i in $CDROM $BLOCK; do + mount -v -r /dev/$i $MEDIA >/dev/null 2>&1 || continue + [ -f $MEDIA/boot/livemedia ] || { umount $MEDIA; continue; } + MEDIAFOUND=1 + break 2 + done + wait=$(( wait + 1 )) + sleep 1 +done + +if [ ! "$MEDIAFOUND" ]; then + echo "Media not found even after 10 seconds" + sh + echo "Cannot go further" + sleep 99999 + exit 1 +fi + +# mount stuffs +loopdevice=$(losetup -f) +losetup -f $SFSIMAGE +mount -r $loopdevice $LOWER +mount -t overlay overlay -o lowerdir=$LOWER,upperdir=$UPPER,workdir=$WORK $NEWROOT +if [ -f $MEDIA/boot/rootfs.gz ]; then + tar -xzaf $MEDIA/boot/rootfs.gz -C $NEWROOT +fi + +kill $pid_mdev + +mount --move /sys $NEWROOT/sys +mount --move /proc $NEWROOT/proc +mount --move /dev $NEWROOT/dev +mount --move /run $NEWROOT/run + +# execute live script if exist +if [ -f $NEWROOT/$MEDIA/boot/live_script.sh ]; then + chroot $NEWROOT sh $MEDIA/boot/live_script.sh +fi + +# switch to newroot +clear +exec /bin/switch_root $NEWROOT /sbin/init + +echo "This is the end of initramfs" +echo "Nothing further, here's the shell" +/bin/busybox sh |