3 # Builds the BootCD reference image, the first of two
4 # initramfs cpio archives that are concatenated together by
5 # isolinux/syslinux to form a custom BootCD.
7 # Aaron Klingaman <alk@absarokasoft.com>
8 # Mark Huang <mlhuang@cs.princeton.edu>
9 # Copyright (C) 2004-2006 The Trustees of Princeton University
12 PATH=/sbin:/bin:/usr/sbin:/usr/bin
14 # In both a normal CVS environment and a PlanetLab RPM
15 # build environment, all of our dependencies are checked out into
16 # directories at the same level as us.
17 if [ -d ../build ] ; then
21 echo "Error: Could not find sources in either . or .."
32 # Packages to install, junk and precious : see build/<pldistro>/bootcd.pkgs
34 # Do not tolerate errors
37 # Root of the initramfs reference image
38 bootcd=$PWD/build/bootcd
39 install -d -m 755 $bootcd
41 # Write version number
42 rpmquery --specfile bootcd.spec --queryformat '%{VERSION}\n' | head -1 > build/version.txt
43 echo $nodefamily > build/nodefamily
46 pl_root_makedevs $bootcd
47 pkgsfile=$(pl_locateDistroFile ../build/ $pldistro bootcd.pkgs)
48 pl_root_mkfedora $bootcd $pldistro $pkgsfile
49 pl_root_tune_image $bootcd
51 # Add site_admin console account to BootCD: with root priv, and empty passwd
52 CRYPT_SA_PASSWORD=$(python -c "import crypt, random, string; salt = [random.choice(string.letters + string.digits + \"./\") for i in range(0,8)] ; print crypt.crypt('site_admin', '\$1\$' + \"\".join(salt) + '\$')")
53 chroot ${bootcd} /usr/sbin/useradd -p "$CRYPT_SA_PASSWORD" -o -g 0 -u 0 -m site_admin
55 # Install ipnmac (for SuperMicro machines with IPMI)
56 echo "* Installing IPMI utilities"
57 install -D -m 755 ipnmac/ipnmac.x86 $bootcd/usr/sbin/ipnmac
60 echo "* Installing initscripts"
61 for file in pl_functions pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
62 sed -i -e "s,@PLDISTRO@,$pldistro,g" -e "s,@FCDISTRO@,$fcdistro,g" initscripts/$file
63 install -D -m 755 initscripts/$file $bootcd/etc/init.d/$file
66 # Install configuration files
67 echo "* Installing configuration files"
68 for file in fstab mtab modprobe.conf inittab hosts sysctl.conf ; do
69 install -D -m 644 etc/$file $bootcd/etc/$file
71 # connect our initscripts scripts for upstart
72 # fedora 9 comes with /sbin/init from upstart, that uses /etc/event.d instead of inittab
73 # (in fact inittab is read for determining the default runlevel)
74 if [ -d $bootcd/etc/event.d ] ; then
75 echo "* Tuning /etc/event.d/ for upstart"
76 pushd $bootcd/etc/event.d
77 # use our system initialisation script
78 sed -i -e 's,/etc/rc\.d/rc\.sysinit[a-z\.]*,/etc/init.d/pl_sysinit,g' rcS
79 # use our startup script in runlevel 2
80 sed -i -e 's,/etc/rc\.d/rc[ \t][ \t]*2,/etc/init.d/pl_boot,g' rc2
82 elif [ -d $bootcd/etc/init ] ; then
83 # ditto for f14 and higher init style
84 echo "* Tuning /etc/init/ for upstart"
85 pushd $bootcd/etc/init
86 # use our system initialisation script
87 sed -i -e 's,/etc/rc\.d/rc\.sysinit[a-z\.]*,/bin/bash -c /etc/init.d/pl_sysinit,g' rcS.conf
88 # use our startup script in runlevel 2
89 sed -i -e 's,/etc/rc.d/rc[a-z\.]*,/etc/init.d/pl_boot,g' rc.conf
93 # Install fallback node configuration file
94 echo "* Installing fallback node configuration file"
95 install -D -m 644 usr-boot/default-node.txt $bootcd/usr/boot/default-node.txt
97 # Copy /etc/passwd out
98 install -D -m 644 $bootcd/etc/passwd build/passwd
101 isofs=$PWD/build/isofs
102 install -d -m 755 $isofs
104 # Copy the kernel out
105 for kernel in $bootcd/boot/vmlinuz-* ; do
106 if [ -f $kernel ] ; then
107 install -D -m 644 $kernel $isofs/kernel
111 # Don't need /boot anymore
114 # initramfs requires that /init be present
115 ln -sf /sbin/init $bootcd/init
117 # Pack the rest into a compressed archive
118 echo "* Compressing reference image"
119 (cd $bootcd && find . | cpio --quiet -c -o) | gzip -9 > $isofs/bootcd.img