3 . /etc/init.d/pl_functions
5 echo pl_sysinit on console > /dev/console
7 echo pl_sysinit on ttyS0 > /dev/ttyS0
10 echo "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
13 echo $(date "+%H:%M:%S") "pl_sysinit: bringing system online"
16 echo $(date "+%H:%M:%S") "pl_sysinit: mounting file systems"
20 echo $(date "+%H:%M:%S") "pl_sysinit: starting udevd"
21 [ -x /sbin/start_udev ] && /sbin/start_udev
24 echo $(date "+%H:%M:%S") "pl_sysinit: invoking hardware initialization script"
30 if [ -f /usr/isolinux/pl_version ] ; 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 initrd_version=$(/bin/cat /pl_version)
35 cd_version=$(/bin/cat /usr/isolinux/pl_version)
36 if [ "$initrd_version" == "$cd_version" ]; then
46 # so that * expands to empty string if there are no block devices
49 for device in /sys/block/*; do
50 device=$(/bin/basename $device)
52 # skipping any devices that start with md or ra (ram) or lo
53 # (loop) or fd (floppy)
55 start_device=${device:0:2}
56 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
57 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
61 # If this is a removable (e.g., USB flash) device, then try to
62 # look for an ISO image on each of its partitions.
63 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
64 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
65 for partition in $partitions ; do
66 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
67 mkdir -p /tmp/$partition
68 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
69 # Look for the first ISO image
70 for iso in /tmp/$partition/*.iso ; do
71 if /sbin/losetup /dev/loop0 $iso ; then
72 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
77 if [ "$device" != "loop0" ] ; then
78 /bin/umount /tmp/$partition 2>&1 > /dev/null
84 echo $(date "+%H:%M:%S") "pl_sysinit: checking $device for /usr contents"
85 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
87 # it mounted, but we should probably make sure its our boot cd
88 # this can be done by making sure the /pl_version file (on initrd)
89 # matches /usr/isolinux/pl_version
90 initrd_version=$(/bin/cat /pl_version)
91 cd_version=$(/bin/cat /usr/isolinux/pl_version)
93 if [ "$initrd_version" != "$cd_version" ]; then
94 # eh, wrong cd, keep trying
95 /bin/umount /usr 2>&1 /dev/null
97 echo $(date "+%H:%M:%S") "pl_sysinit: found cd and mounted on /usr"
106 echo $(date "+%H:%M:%S") "pl_sysinit: finding cd to mount on /usr"
109 if [ $? -eq 1 ]; then
112 [ ! -d /usr ] && mkdir /usr
114 [ $? -eq 1 ] && mounted=1
117 if [ $mounted -eq 0 ]; then
118 echo $(date "+%H:%M:%S") "pl_sysinit: unable to find boot cdrom, cannot continue."
119 # todo: maybe we can put a staticly linked sshd here
120 /sbin/shutdown -h now
124 # parts of this were copied from devmap_mknod.sh from the device-mapper
125 # source. Since fedora decided not to include it in the rpm, it is
127 echo $(date "+%H:%M:%S") "pl_sysinit: creating device mapper control node"
130 DM_NAME="device-mapper"
132 CONTROL="$DIR/control"
134 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
135 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
137 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
138 /bin/mkdir -p --mode=755 $DIR
140 /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
142 echo $(date "+%H:%M:%S") "pl_sysinit: unable to create device mapper control node, continuing"
146 echo $(date "+%H:%M:%S") "pl_sysinit: configuring kernel parameters"
147 /sbin/sysctl -e -p /etc/sysctl.conf
149 # startup rsyslog if available (we're *NOT* running the standard rc)
150 syslog=/etc/rc.d/init.d/rsyslog
151 [ -x $syslog ] && $syslog start
154 echo $(date "+%H:%M:%S") "pl_sysinit: bringing network online"
155 /etc/init.d/pl_netinit
157 # just in case, sometimes we're seeing weird stuff already at this point
158 pl_network_sanity_checks
161 echo $(date "+%H:%M:%S") "pl_sysinit: attempting to sync clock"
162 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
164 # Handle /dev/rtc name change for newer kernels
165 # otherwise hwclock fails
166 baseMaj=`uname -r | cut -d "." -f1`
167 baseMin=`uname -r | cut -d "." -f2`
168 vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
169 if [ $baseMaj -eq 2 ];then
170 if [ $baseMin -eq 6 ]; then
171 if [ $vers -ge 32 ];then
172 if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
174 ln -s /dev/rtc0 /dev/rtc
180 # save ntp clock to hardware
181 /sbin/hwclock --systohc --utc