3 ### make sure this output shows up in the console
9 . /etc/init.d/pl_functions
11 verbose-message "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
13 verbose-message "pl_sysinit: bringing system online"
15 verbose-message "pl_sysinit: mounting file systems"
16 verbose-run /bin/mount -v -a
18 if [ -x /sbin/start_udev ]; then
19 verbose-message "pl_sysinit: starting udev daemon"
20 verbose-run /sbin/start_udev
22 verbose-message "pl_sysinit: WARNING cannot start udev daemon - /sbin/start_udev NOT FOUND"
25 verbose-message "pl_sysinit: invoking hardware initialization script"
26 verbose-run /etc/init.d/pl_hwinit
28 function check-initrd() {
30 if [ -f /usr/isolinux/pl_version ] ; then
31 # it is 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 initrd_version=$(/bin/cat /pl_version)
35 cd_version=$(/bin/cat /usr/isolinux/pl_version)
36 if [ "$initrd_version" == "$cd_version" ]; then
39 verbose-message "pl_sysinit: WARNING pl_version mismatch"
45 function check-block-devices() {
47 # so that * expands to empty string if there are no block devices
50 for device in /sys/block/*; do
51 device=$(/bin/basename $device)
53 # skipping any devices that start with md or ra (ram) or lo
54 # (loop) or fd (floppy)
56 start_device=${device:0:2}
57 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
58 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
62 # If this is a removable (e.g., USB flash) device, then try to
63 # look for an ISO image on each of its partitions.
64 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
65 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
66 for partition in $partitions ; do
67 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
68 mkdir -p /tmp/$partition
69 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
70 # Look for the first ISO image
71 for iso in /tmp/$partition/*.iso ; do
72 if /sbin/losetup /dev/loop0 $iso ; then
73 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
78 if [ "$device" != "loop0" ] ; then
79 /bin/umount /tmp/$partition 2>&1 > /dev/null
85 verbose-message "pl_sysinit: checking $device for /usr contents"
86 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
88 # it mounted, but we should probably make sure its our boot cd
89 # this can be done by making sure the /pl_version file (on initrd)
90 # matches /usr/isolinux/pl_version
91 initrd_version=$(/bin/cat /pl_version)
92 cd_version=$(/bin/cat /usr/isolinux/pl_version)
94 if [ "$initrd_version" != "$cd_version" ]; then
95 # eh, wrong cd, keep trying
96 /bin/umount /usr 2>&1 /dev/null
98 verbose-message "pl_sysinit: found CD and mounted on /usr"
107 verbose-message "pl_sysinit: finding CD to mount on /usr"
110 if [ $? -eq 1 ]; then
113 [ ! -d /usr ] && mkdir /usr
115 [ $? -eq 1 ] && mounted=1
118 if [ $mounted -eq 0 ]; then
119 hang-and-shutdown "pl_sysinit: ERROR - unable to find boot CD"
123 # parts of this were copied from devmap_mknod.sh from the device-mapper
124 # source. Since fedora decided not to include it in the rpm, it is
126 function create-device-mapper-node() {
129 DM_NAME="device-mapper"
131 CONTROL="$DIR/control"
133 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
134 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
136 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
137 /bin/mkdir -p --mode=755 $DIR
139 /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
141 verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
145 verbose-message "pl_sysinit: creating device mapper control node"
146 create-device-mapper-node
148 verbose-message "pl_sysinit: configuring kernel parameters"
149 verbose-run /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 if [ -x $syslog ]; then
154 verbose-message "pl_sysinit: starting rsyslog"
155 verbose-run $syslog start
157 verbose-message "pl_sysinit: WARNING cannot start rsyslog"
160 verbose-message "pl_sysinit: bringing network online"
161 verbose-run /etc/init.d/pl_netinit
163 function 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
181 # save ntp clock to hardware
182 /sbin/hwclock --systohc --utc
185 verbose-message "pl_sysinit: attempting to sync clock"