50a6b5cb3c46b67960e8d25e4cbdd221c8e7bcab
[bootcd.git] / conf_files / pl_sysinit
1 #!/bin/sh
2
3 echo "pl_sysinit: bringing system online"
4
5 echo "pl_sysinit: mounting file systems"
6 /bin/mount -v -a
7
8 echo "pl_sysinit: invoking hardware initialization script"
9 /etc/init.d/pl_hwinit
10
11 echo "pl_sysinit: finding cd to mount on /usr"
12 test_devices=/sys/block/*
13 mounted=0
14 initrd_version=$(/bin/cat /pl_version)
15 mkdir /usr
16
17 for device in $test_devices; do
18     device=$(/bin/basename $device)
19
20     # skipping any devices that start with md or ra (ram) or lo (loop) or
21     # fd (floppy)
22     start_device=${device:0:2}
23     if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
24         [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
25         continue
26     fi
27     
28     echo "pl_sysinit: checking $device for /usr contents"
29     /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
30     if [ $? -eq 0 ]; then
31         # it mounted, but we should probably make sure its our boot cd
32         # this can be done by making sure the /pl_version file (on initrd)
33         # matches /usr/isolinux/pl_version
34         cd_version=$(/bin/cat /usr/isolinux/pl_version)
35
36         if [ "$initrd_version" != "$cd_version" ]; then
37             # eh, wrong cd, keep trying
38             /bin/umount /usr 2>&1 /dev/null
39         else
40             echo "pl_sysinit: found cd and mounted on /usr"
41             mounted=1
42             break
43         fi
44     fi
45 done
46
47 if [ $mounted -eq 0 ]; then
48     echo "pl_sysinit: unable to find boot cdrom, cannot continue."
49     # todo: maybe we can put a staticly linked sshd here
50     /sbin/shutdown -h now
51 fi
52
53
54 # parts of this were copied from devmap_mknod.sh from the device-mapper
55 # source. Since fedora decided not to include it in the rpm, it is 
56 # being copied here
57 echo "pl_sysinit: creating device mapper control node"
58
59 DM_DIR="mapper"
60 DM_NAME="device-mapper"
61 DIR="/dev/$DM_DIR"
62 CONTROL="$DIR/control"
63
64 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
65 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
66
67 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
68     /bin/mkdir -p --mode=755 $DIR
69     /bin/rm -f $CONTROL
70     /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
71 else
72     echo "pl_sysinit: unable to create device mapper control node, continuing"
73 fi
74
75 echo "pl_sysinit: configuring kernel parameters"
76 /sbin/sysctl -e -p /etc/sysctl.conf
77
78 echo "pl_sysinit: bringing network online"
79 /etc/init.d/pl_netinit
80