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