#!/bin/sh
MNTROOT=/mnt/sysimage
cd ${MNTROOT}/boot
mkdir work
cd work
gzip -dc ../initrd.img | cpio -idmv

find ${MNTROOT}/lib/modules -name uhci-hcd.ko -exec cp -p {} lib \;
find ${MNTROOT}/lib/modules -name ohci-hcd.ko -exec cp -p {} lib \;
find ${MNTROOT}/lib/modules -name ehci-hcd.ko -exec cp -p {} lib \;

patch -p0 <<EOT
--- init.orig	2008-01-03 22:20:36.000000000 +0900
+++ init	2008-01-03 23:10:56.000000000 +0900
@@ -5,6 +5,12 @@
 echo Mounted /proc filesystem
 echo Mounting sysfs
 mount -t sysfs none /sys
+echo "Loading uhci-hcd.ko module"
+insmod /lib/uhci-hcd.ko 
+echo "Loading ohci-hcd.ko module"
+insmod /lib/ohci-hcd.ko 
+echo "Loading ehci-hcd.ko module"
+insmod /lib/ehci-hcd.ko 
 echo "Loading scsi_mod.ko module"
 insmod /lib/scsi_mod.ko 
 echo "Loading sd_mod.ko module"
EOT
chmod +x init

find | cpio -H newc -o | gzip -9 > ../initrd.img
