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 # on old systems that use init, we totally take control and replace
19 # /etc/inittab with just our stuff, so nothing is going to run udev
20 # for us and we need to start it ourselves
21 if [ -x /sbin/start_udev ]; then
22 verbose-message "pl_sysinit: starting udev daemon"
23 verbose-run /sbin/start_udev
25 # on systemd-based systems, udev is triggered by systemd
26 # but just in case we issue a warning
27 verbose-message "pl_sysinit: WARNING cannot start udev daemon (probably safe under systemd)"
30 verbose-message "pl_sysinit: invoking hardware initialization script"
31 verbose-run /etc/init.d/pl_hwinit
33 function check-initrd() {
35 if [ -f /usr/isolinux/pl_version ] ; then
36 # it is mounted, but we should probably make sure its our boot cd
37 # this can be done by making sure the /pl_version file (on initrd)
38 # matches /usr/isolinux/pl_version
39 initrd_version=$(/bin/cat /pl_version)
40 cd_version=$(/bin/cat /usr/isolinux/pl_version)
41 if [ "$initrd_version" == "$cd_version" ]; then
44 verbose-message "pl_sysinit: WARNING pl_version mismatch"
50 function check-block-devices() {
52 # so that * expands to empty string if there are no block devices
55 for device in /sys/block/*; do
56 device=$(/bin/basename $device)
58 # skipping any devices that start with md or ra (ram) or lo
59 # (loop) or fd (floppy)
61 start_device=${device:0:2}
62 if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
63 [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
67 # If this is a removable (e.g., USB flash) device, then try to
68 # look for an ISO image on each of its partitions.
69 if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
70 partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
71 for partition in $partitions ; do
72 echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
73 mkdir -p /tmp/$partition
74 if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
75 # Look for the first ISO image
76 for iso in /tmp/$partition/*.iso ; do
77 if /sbin/losetup /dev/loop0 $iso ; then
78 echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
83 if [ "$device" != "loop0" ] ; then
84 /bin/umount /tmp/$partition 2>&1 > /dev/null
90 verbose-message "pl_sysinit: checking $device for /usr contents"
91 /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
93 # it mounted, but we should probably make sure its our boot cd
94 # this can be done by making sure the /pl_version file (on initrd)
95 # matches /usr/isolinux/pl_version
96 initrd_version=$(/bin/cat /pl_version)
97 cd_version=$(/bin/cat /usr/isolinux/pl_version)
99 if [ "$initrd_version" != "$cd_version" ]; then
100 # eh, wrong cd, keep trying
101 /bin/umount /usr 2>&1 /dev/null
103 verbose-message "pl_sysinit: found CD and mounted on /usr"
112 verbose-message "pl_sysinit: finding CD to mount on /usr"
115 if [ $? -eq 1 ]; then
118 [ ! -d /usr ] && mkdir /usr
120 [ $? -eq 1 ] && mounted=1
123 if [ $mounted -eq 0 ]; then
124 hang-and-shutdown "pl_sysinit: ERROR - unable to find boot CD"
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 function create-device-mapper-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 verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
150 verbose-message "pl_sysinit: creating device mapper control node"
151 create-device-mapper-node
153 verbose-message "pl_sysinit: configuring kernel parameters"
154 verbose-run /sbin/sysctl -e -p /etc/sysctl.conf
156 # startup rsyslog if available (we're *NOT* running the standard rc)
157 syslog=/etc/rc.d/init.d/rsyslog
158 if [ -x $syslog ]; then
159 verbose-message "pl_sysinit: starting rsyslog"
160 verbose-run $syslog start
162 verbose-message "pl_sysinit: WARNING cannot start rsyslog"
165 verbose-message "pl_sysinit: bringing network online"
166 verbose-run /etc/init.d/pl_netinit
168 function sync-clock() {
169 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
171 # Handle /dev/rtc name change for newer kernels
172 # otherwise hwclock fails
173 baseMaj=`uname -r | cut -d "." -f1`
174 baseMin=`uname -r | cut -d "." -f2`
175 vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
176 if [ $baseMaj -eq 2 ];then
177 if [ $baseMin -eq 6 ]; then
178 if [ $vers -ge 32 ];then
179 if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
181 ln -s /dev/rtc0 /dev/rtc
186 # save ntp clock to hardware
187 /sbin/hwclock --systohc --utc
190 verbose-message "pl_sysinit: attempting to sync clock"