3 ### make sure this output shows up in the console
9 . /etc/init.d/pl_functions
12 echo "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
15 echo $(date "+%H:%M:%S") "pl_sysinit: bringing system online"
18 echo $(date "+%H:%M:%S") "pl_sysinit: mounting file systems"
22 echo $(date "+%H:%M:%S") "pl_sysinit: starting udevd"
23 [ -x /sbin/start_udev ] && /sbin/start_udev
26 echo $(date "+%H:%M:%S") "pl_sysinit: invoking hardware initialization script"
32 if [ -f /usr/isolinux/pl_version ] ; 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 initrd_version=$(/bin/cat /pl_version)
37 cd_version=$(/bin/cat /usr/isolinux/pl_version)
38 if [ "$initrd_version" == "$cd_version" ]; then
48 # so that * expands to empty string if there are no block devices
51 for device in /sys/block/*; do
52 device=$(/bin/basename $device)
54 # skipping any devices that start with md or ra (ram) or lo
55 # (loop) or fd (floppy)
57 start_device=${device:0:2}
58 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
59 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
63 # If this is a removable (e.g., USB flash) device, then try to
64 # look for an ISO image on each of its partitions.
65 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
66 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
67 for partition in $partitions ; do
68 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
69 mkdir -p /tmp/$partition
70 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
71 # Look for the first ISO image
72 for iso in /tmp/$partition/*.iso ; do
73 if /sbin/losetup /dev/loop0 $iso ; then
74 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
79 if [ "$device" != "loop0" ] ; then
80 /bin/umount /tmp/$partition 2>&1 > /dev/null
86 echo $(date "+%H:%M:%S") "pl_sysinit: checking $device for /usr contents"
87 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
89 # it mounted, but we should probably make sure its our boot cd
90 # this can be done by making sure the /pl_version file (on initrd)
91 # matches /usr/isolinux/pl_version
92 initrd_version=$(/bin/cat /pl_version)
93 cd_version=$(/bin/cat /usr/isolinux/pl_version)
95 if [ "$initrd_version" != "$cd_version" ]; then
96 # eh, wrong cd, keep trying
97 /bin/umount /usr 2>&1 /dev/null
99 echo $(date "+%H:%M:%S") "pl_sysinit: found cd and mounted on /usr"
108 echo $(date "+%H:%M:%S") "pl_sysinit: finding cd to mount on /usr"
111 if [ $? -eq 1 ]; then
114 [ ! -d /usr ] && mkdir /usr
116 [ $? -eq 1 ] && mounted=1
119 if [ $mounted -eq 0 ]; then
120 echo $(date "+%H:%M:%S") "pl_sysinit: unable to find boot cdrom, cannot continue."
121 # todo: maybe we can put a staticly linked sshd here
122 /sbin/shutdown -h now
126 # parts of this were copied from devmap_mknod.sh from the device-mapper
127 # source. Since fedora decided not to include it in the rpm, it is
129 echo $(date "+%H:%M:%S") "pl_sysinit: creating device mapper control node"
132 DM_NAME="device-mapper"
134 CONTROL="$DIR/control"
136 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
137 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
139 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
140 /bin/mkdir -p --mode=755 $DIR
142 /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
144 echo $(date "+%H:%M:%S") "pl_sysinit: unable to create device mapper control node, continuing"
148 echo $(date "+%H:%M:%S") "pl_sysinit: configuring kernel parameters"
149 /sbin/sysctl -e -p /etc/sysctl.conf
151 # startup rsyslog if available (we're *NOT* running the standard rc)
152 syslog=/etc/rc.d/init.d/rsyslog
153 [ -x $syslog ] && $syslog start
156 echo $(date "+%H:%M:%S") "pl_sysinit: bringing network online"
157 /etc/init.d/pl_netinit
159 # just in case, sometimes we're seeing weird stuff already at this point
160 pl_network_sanity_checks
163 echo $(date "+%H:%M:%S") "pl_sysinit: attempting to sync clock"
164 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
166 # Handle /dev/rtc name change for newer kernels
167 # otherwise hwclock fails
168 baseMaj=`uname -r | cut -d "." -f1`
169 baseMin=`uname -r | cut -d "." -f2`
170 vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
171 if [ $baseMaj -eq 2 ];then
172 if [ $baseMin -eq 6 ]; then
173 if [ $vers -ge 32 ];then
174 if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
176 ln -s /dev/rtc0 /dev/rtc
182 # save ntp clock to hardware
183 /sbin/hwclock --systohc --utc