4 echo "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
7 echo $(date "+%H:%M:%S") "pl_sysinit: bringing system online"
10 echo $(date "+%H:%M:%S") "pl_sysinit: mounting file systems"
14 echo $(date "+%H:%M:%S") "pl_sysinit: starting udevd"
15 [ -x /sbin/start_udev ] && /sbin/start_udev
18 echo $(date "+%H:%M:%S") "pl_sysinit: invoking hardware initialization script"
24 if [ -f /usr/isolinux/pl_version ] ; then
25 # it mounted, but we should probably make sure its our boot cd
26 # this can be done by making sure the /pl_version file (on initrd)
27 # matches /usr/isolinux/pl_version
28 initrd_version=$(/bin/cat /pl_version)
29 cd_version=$(/bin/cat /usr/isolinux/pl_version)
30 if [ "$initrd_version" == "$cd_version" ]; then
40 # so that * expands to empty string if there are no block devices
43 for device in /sys/block/*; do
44 device=$(/bin/basename $device)
46 # skipping any devices that start with md or ra (ram) or lo
47 # (loop) or fd (floppy)
49 start_device=${device:0:2}
50 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
51 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
55 # If this is a removable (e.g., USB flash) device, then try to
56 # look for an ISO image on each of its partitions.
57 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
58 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
59 for partition in $partitions ; do
60 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
61 mkdir -p /tmp/$partition
62 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
63 # Look for the first ISO image
64 for iso in /tmp/$partition/*.iso ; do
65 if /sbin/losetup /dev/loop0 $iso ; then
66 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
71 if [ "$device" != "loop0" ] ; then
72 /bin/umount /tmp/$partition 2>&1 > /dev/null
78 echo $(date "+%H:%M:%S") "pl_sysinit: checking $device for /usr contents"
79 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
81 # it mounted, but we should probably make sure its our boot cd
82 # this can be done by making sure the /pl_version file (on initrd)
83 # matches /usr/isolinux/pl_version
84 initrd_version=$(/bin/cat /pl_version)
85 cd_version=$(/bin/cat /usr/isolinux/pl_version)
87 if [ "$initrd_version" != "$cd_version" ]; then
88 # eh, wrong cd, keep trying
89 /bin/umount /usr 2>&1 /dev/null
91 echo $(date "+%H:%M:%S") "pl_sysinit: found cd and mounted on /usr"
100 echo $(date "+%H:%M:%S") "pl_sysinit: finding cd to mount on /usr"
103 if [ $? -eq 1 ]; then
106 [ ! -d /usr ] && mkdir /usr
108 [ $? -eq 1 ] && mounted=1
111 if [ $mounted -eq 0 ]; then
112 echo $(date "+%H:%M:%S") "pl_sysinit: unable to find boot cdrom, cannot continue."
113 # todo: maybe we can put a staticly linked sshd here
114 /sbin/shutdown -h now
118 # parts of this were copied from devmap_mknod.sh from the device-mapper
119 # source. Since fedora decided not to include it in the rpm, it is
121 echo $(date "+%H:%M:%S") "pl_sysinit: creating device mapper control node"
124 DM_NAME="device-mapper"
126 CONTROL="$DIR/control"
128 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
129 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
131 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
132 /bin/mkdir -p --mode=755 $DIR
134 /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
136 echo $(date "+%H:%M:%S") "pl_sysinit: unable to create device mapper control node, continuing"
140 echo $(date "+%H:%M:%S") "pl_sysinit: configuring kernel parameters"
141 /sbin/sysctl -e -p /etc/sysctl.conf
144 echo $(date "+%H:%M:%S") "pl_sysinit: bringing network online"
145 /etc/init.d/pl_netinit
148 echo $(date "+%H:%M:%S") "pl_sysinit: attempting to sync clock"
149 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
150 # save ntp clock to hardware
151 /sbin/hwclock --systohc --utc