exec > /dev/console
###
-. /etc/init.d/pl_functions
+source /etc/init.d/pl_functions
verbose-message "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
verbose-message "pl_sysinit: mounting file systems"
verbose-run /bin/mount -v -a
+# on old systems that use init, we totally take control and replace
+# /etc/inittab with just our stuff, so nothing is going to run udev
+# for us and we need to start it ourselves
if [ -x /sbin/start_udev ]; then
verbose-message "pl_sysinit: starting udev daemon"
verbose-run /sbin/start_udev
else
- verbose-message "pl_sysinit: WARNING cannot start udev daemon - /sbin/start_udev NOT FOUND"
+ # on systemd-based systems, udev is triggered by systemd
+ # but just in case we issue a warning
+ verbose-message "pl_sysinit: WARNING cannot start udev daemon (probably safe under systemd)"
fi
verbose-message "pl_sysinit: invoking hardware initialization script"
# it is mounted, but we should probably make sure its our boot cd
# this can be done by making sure the /pl_version file (on initrd)
# matches /usr/isolinux/pl_version
- initrd_version=$(/bin/cat /pl_version)
- cd_version=$(/bin/cat /usr/isolinux/pl_version)
- if [ "$initrd_version" == "$cd_version" ]; then
- _mounted=1
- else
- verbose-message "pl_sysinit: WARNING pl_version mismatch"
- fi
+ initrd_version=$(/bin/cat /pl_version)
+ cd_version=$(/bin/cat /usr/isolinux/pl_version)
+ if [ "$initrd_version" == "$cd_version" ]; then
+ _mounted=1
+ else
+ verbose-message "pl_sysinit: WARNING pl_version mismatch"
+ fi
fi
return $_mounted
}
shopt -s nullglob
for device in /sys/block/*; do
- device=$(/bin/basename $device)
+ device=$(/bin/basename $device)
# skipping any devices that start with md or ra (ram) or lo
- # (loop) or fd (floppy)
+ # (loop) or fd (floppy)
- start_device=${device:0:2}
- if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
- [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
- continue
- fi
+ start_device=${device:0:2}
+ if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
+ [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
+ continue
+ fi
# If this is a removable (e.g., USB flash) device, then try to
# look for an ISO image on each of its partitions.
- if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
- partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
- for partition in $partitions ; do
- echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
- mkdir -p /tmp/$partition
- if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
- # Look for the first ISO image
- for iso in /tmp/$partition/*.iso ; do
- if /sbin/losetup /dev/loop0 $iso ; then
- echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
- device="loop0"
- break
- fi
- done
- if [ "$device" != "loop0" ] ; then
- /bin/umount /tmp/$partition 2>&1 > /dev/null
- fi
- fi
- done
- fi
-
- verbose-message "pl_sysinit: checking $device for /usr contents"
- /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
- if [ $? -eq 0 ]; then
- # it mounted, but we should probably make sure its our boot cd
- # this can be done by making sure the /pl_version file (on initrd)
- # matches /usr/isolinux/pl_version
- initrd_version=$(/bin/cat /pl_version)
- cd_version=$(/bin/cat /usr/isolinux/pl_version)
-
- if [ "$initrd_version" != "$cd_version" ]; then
- # eh, wrong cd, keep trying
- /bin/umount /usr 2>&1 /dev/null
- else
- verbose-message "pl_sysinit: found CD and mounted on /usr"
- _mounted=1
- break
- fi
- fi
+ if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
+ partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
+ for partition in $partitions ; do
+ echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
+ mkdir -p /tmp/$partition
+ if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
+ # Look for the first ISO image
+ for iso in /tmp/$partition/*.iso ; do
+ if /sbin/losetup /dev/loop0 $iso ; then
+ echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
+ device="loop0"
+ break
+ fi
+ done
+ if [ "$device" != "loop0" ] ; then
+ /bin/umount /tmp/$partition 2>&1 > /dev/null
+ fi
+ fi
+ done
+ fi
+
+ verbose-message "pl_sysinit: checking $device for /usr contents"
+ /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
+ if [ $? -eq 0 ]; then
+ # it mounted, but we should probably make sure its our boot cd
+ # this can be done by making sure the /pl_version file (on initrd)
+ # matches /usr/isolinux/pl_version
+ initrd_version=$(/bin/cat /pl_version)
+ cd_version=$(/bin/cat /usr/isolinux/pl_version)
+
+ if [ "$initrd_version" != "$cd_version" ]; then
+ # eh, wrong cd, keep trying
+ /bin/umount /usr 2>&1 /dev/null
+ else
+ verbose-message "pl_sysinit: found CD and mounted on /usr"
+ _mounted=1
+ break
+ fi
+ fi
done
return $_mounted
}
fi
# parts of this were copied from devmap_mknod.sh from the device-mapper
-# source. Since fedora decided not to include it in the rpm, it is
+# source. Since fedora decided not to include it in the rpm, it is
# being copied here
function create-device-mapper-node() {
MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
-
+
if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
- /bin/mkdir -p --mode=755 $DIR
- /bin/rm -f $CONTROL
- /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
+ /bin/mkdir -p --mode=755 $DIR
+ /bin/rm -f $CONTROL
+ /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
else
- verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
+ verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
fi
}
create-device-mapper-node
verbose-message "pl_sysinit: configuring kernel parameters"
-verbose-run /sbin/sysctl -e -p /etc/sysctl.conf
+verbose-run /sbin/sysctl -e -p /etc/sysctl.conf
# startup rsyslog if available (we're *NOT* running the standard rc)
syslog=/etc/rc.d/init.d/rsyslog
if [ -x $syslog ]; then
verbose-message "pl_sysinit: starting rsyslog"
- verbose-run $syslog start
+ verbose-run $syslog start
else
verbose-message "pl_sysinit: WARNING cannot start rsyslog"
fi
verbose-message "pl_sysinit: bringing network online"
-verbose-run /etc/init.d/pl_netinit
+verbose-run /etc/init.d/pl_netinit
function sync-clock() {
/usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
baseMin=`uname -r | cut -d "." -f2`
vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
if [ $baseMaj -eq 2 ];then
- if [ $baseMin -eq 6 ]; then
+ if [ $baseMin -eq 6 ]; then
if [ $vers -ge 32 ];then
- if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
+ if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
rm -f /dev/rtc
ln -s /dev/rtc0 /dev/rtc
- fi
+ fi
fi
- fi
+ fi
fi
# save ntp clock to hardware
/sbin/hwclock --systohc --utc