Added a "trampoline" init so as to deploy the iso initrd automagically.
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Sat, 17 Jun 2023 01:31:21 +0000 (11:31 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Sat, 17 Jun 2023 01:31:21 +0000 (11:31 +1000)
init/init [new file with mode: 0644]

diff --git a/init/init b/init/init
new file mode 100644 (file)
index 0000000..23b40ac
--- /dev/null
+++ b/init/init
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# This script is intended to be interpreted by busybox sh.
+echo
+echo "Starting..."
+echo
+
+mkdir /cdrom
+mkdir /target
+
+for M in proc:/proc devtmpfs:/dev devpts:/dev/pts sysfs:/sys ; do
+    mkdir -p ${M##*:}
+    mount -t ${M%%:*} ${M%%:*} ${M##*:}
+done
+
+for M in ata_piix sd_mod sr_mod isofs vfat xhci-pci usb_storage ; do
+    modprobe $M
+    sleep 1
+done
+
+#--- Automatic:
+# cdrom t10_pi crc64_rocksoft crc64 crc_t10dif crct10dif_common libata
+# scsi_mod scsi_common
+#--- Other, not used:
+# ata_generic nls_cp437 nls_ascii sg
+#  ext4 jbd2 mbcache crc16
+#-- input
+# psmouse evdev
+#-- network
+# e1000
+
+echo
+echo "Continuing..."
+echo
+
+# Determine root fs from FSUUID provided by syslinux SYSAPPEND
+for I in 1 2 3 4 5 ; do
+    sleep $I
+    mount UUID=${FSUUID} /boot && break
+    if [ $I -eq 5 ] ; then
+       echo "CANNOT MOUNT UUID=${FSUUID}"
+       echo "Starting emergency shell ..."
+       exec /bin/sh
+    fi
+done
+DEV2="$(grep /boot /proc/mounts | sed 's/ .*//')"
+umount /boot
+DEV="${DEV2%?}"
+
+mount $DEV /cdrom
+mount -t ramfs -o size=1G initrd /target
+
+gunzip < $(find /cdrom -name initrd.gz ) | ( cd /target && cpio -i )
+#exec /bin/sh
+exec switch_root -c /dev/console /target /init