This commit was generated by cvs2svn to compensate for changes in r525,
[bootcd.git] / conf_files / pl_sysinit
diff --git a/conf_files/pl_sysinit b/conf_files/pl_sysinit
new file mode 100755 (executable)
index 0000000..0fded15
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+echo "pl_sysinit: bringing system online"
+
+echo "pl_sysinit: mounting file systems"
+/bin/mount -v -a
+
+echo "pl_sysinit: bringing loopback network device up"
+/sbin/ifconfig lo 127.0.0.1 up
+
+echo "pl_sysinit: invoking hardware initialization script"
+/etc/init.d/pl_hwinit
+
+echo "pl_sysinit: finding cd to mount on /usr"
+test_devices=/sys/block/*
+mounted=0
+initrd_version=$(/bin/cat /pl_version)
+mkdir /usr
+
+for device in $test_devices; do
+    device=$(/bin/basename $device)
+
+    # skipping any devices that start with md or ra (ram) or lo (loop)
+    start_device=${device:0:2}
+    if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
+       [ "$start_device" == "lo" ]; then
+       continue
+    fi
+    
+    echo "pl_sysinit: checking $device for /usr contents"
+    /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
+    if [ $? -eq 0 ]; then
+       # it mounted, but we should probably make sure its our boot cd
+       # this can be done by making sure the /pl_version file (on initrd)
+       # matches /usr/isolinux/pl_version
+       cd_version=$(/bin/cat /usr/isolinux/pl_version)
+
+       if [ "$initrd_version" != "$cd_version" ]; then
+           # eh, wrong cd, keep trying
+           /bin/umount /usr 2>&1 /dev/null
+       else
+           echo "pl_sysinit: found cd and mounted on /usr"
+           mounted=1
+           break
+       fi
+    fi
+done
+
+if [ $mounted -eq 0 ]; then
+    echo "pl_sysinit: unable to find boot cdrom, cannot continue."
+    # todo: maybe we can put a staticly linked sshd here
+    /sbin/shutdown -h now
+fi
+
+
+# parts of this were copied from devmap_mknod.sh from the device-mapper
+# source. Since fedora decided not to include it in the rpm, it is 
+# being copied here
+echo "pl_sysinit: creating device mapper control node"
+
+DM_DIR="mapper"
+DM_NAME="device-mapper"
+DIR="/dev/$DM_DIR"
+CONTROL="$DIR/control"
+
+MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
+MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
+
+if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
+    /bin/mkdir -p --mode=755 $DIR
+    /bin/rm -f $CONTROL
+    /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
+else
+    echo "pl_sysinit: unable to create device mapper control node, continuing"
+fi
+