6 echo pl_sysinit on console > /dev/console
11 . /etc/init.d/pl_functions
14 echo "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
17 echo $(date "+%H:%M:%S") "pl_sysinit: bringing system online"
20 echo $(date "+%H:%M:%S") "pl_sysinit: mounting file systems"
24 echo $(date "+%H:%M:%S") "pl_sysinit: starting udevd"
25 [ -x /sbin/start_udev ] && /sbin/start_udev
28 echo $(date "+%H:%M:%S") "pl_sysinit: invoking hardware initialization script"
34 if [ -f /usr/isolinux/pl_version ] ; then
35 # it mounted, but we should probably make sure its our boot cd
36 # this can be done by making sure the /pl_version file (on initrd)
37 # matches /usr/isolinux/pl_version
38 initrd_version=$(/bin/cat /pl_version)
39 cd_version=$(/bin/cat /usr/isolinux/pl_version)
40 if [ "$initrd_version" == "$cd_version" ]; then
50 # so that * expands to empty string if there are no block devices
53 for device in /sys/block/*; do
54 device=$(/bin/basename $device)
56 # skipping any devices that start with md or ra (ram) or lo
57 # (loop) or fd (floppy)
59 start_device=${device:0:2}
60 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
61 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
65 # If this is a removable (e.g., USB flash) device, then try to
66 # look for an ISO image on each of its partitions.
67 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
68 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
69 for partition in $partitions ; do
70 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
71 mkdir -p /tmp/$partition
72 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
73 # Look for the first ISO image
74 for iso in /tmp/$partition/*.iso ; do
75 if /sbin/losetup /dev/loop0 $iso ; then
76 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
81 if [ "$device" != "loop0" ] ; then
82 /bin/umount /tmp/$partition 2>&1 > /dev/null
88 echo $(date "+%H:%M:%S") "pl_sysinit: checking $device for /usr contents"
89 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
91 # it mounted, but we should probably make sure its our boot cd
92 # this can be done by making sure the /pl_version file (on initrd)
93 # matches /usr/isolinux/pl_version
94 initrd_version=$(/bin/cat /pl_version)
95 cd_version=$(/bin/cat /usr/isolinux/pl_version)
97 if [ "$initrd_version" != "$cd_version" ]; then
98 # eh, wrong cd, keep trying
99 /bin/umount /usr 2>&1 /dev/null
101 echo $(date "+%H:%M:%S") "pl_sysinit: found cd and mounted on /usr"
110 echo $(date "+%H:%M:%S") "pl_sysinit: finding cd to mount on /usr"
113 if [ $? -eq 1 ]; then
116 [ ! -d /usr ] && mkdir /usr
118 [ $? -eq 1 ] && mounted=1
121 if [ $mounted -eq 0 ]; then
122 echo $(date "+%H:%M:%S") "pl_sysinit: unable to find boot cdrom, cannot continue."
123 # todo: maybe we can put a staticly linked sshd here
124 /sbin/shutdown -h now
128 # parts of this were copied from devmap_mknod.sh from the device-mapper
129 # source. Since fedora decided not to include it in the rpm, it is
131 echo $(date "+%H:%M:%S") "pl_sysinit: creating device mapper control node"
134 DM_NAME="device-mapper"
136 CONTROL="$DIR/control"
138 MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
139 MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
141 if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
142 /bin/mkdir -p --mode=755 $DIR
144 /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
146 echo $(date "+%H:%M:%S") "pl_sysinit: unable to create device mapper control node, continuing"
150 echo $(date "+%H:%M:%S") "pl_sysinit: configuring kernel parameters"
151 /sbin/sysctl -e -p /etc/sysctl.conf
153 # startup rsyslog if available (we're *NOT* running the standard rc)
154 syslog=/etc/rc.d/init.d/rsyslog
155 [ -x $syslog ] && $syslog start
158 echo $(date "+%H:%M:%S") "pl_sysinit: bringing network online"
159 /etc/init.d/pl_netinit
161 # just in case, sometimes we're seeing weird stuff already at this point
162 pl_network_sanity_checks
165 echo $(date "+%H:%M:%S") "pl_sysinit: attempting to sync clock"
166 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
168 # Handle /dev/rtc name change for newer kernels
169 # otherwise hwclock fails
170 baseMaj=`uname -r | cut -d "." -f1`
171 baseMin=`uname -r | cut -d "." -f2`
172 vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
173 if [ $baseMaj -eq 2 ];then
174 if [ $baseMin -eq 6 ]; then
175 if [ $vers -ge 32 ];then
176 if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
178 ln -s /dev/rtc0 /dev/rtc
184 # save ntp clock to hardware
185 /sbin/hwclock --systohc --utc