3 # Builds custom BootCD ISO and USB images in the current
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2004-2006 The Trustees of Princeton University
9 # $Id: build.sh,v 1.42 2006/11/22 20:40:48 mef Exp $
12 PATH=/sbin:/bin:/usr/sbin:/usr/bin
16 if [ -f /etc/planetlab/plc_config ] ; then
17 # Source PLC configuration
18 . /etc/planetlab/plc_config
20 echo "Could not find /etc/planetlab/plc_config."
21 echo "This file defines the configuration of your PlanetLab installation."
25 output="$PLC_NAME-BootCD-$BOOTCD_VERSION.iso"
29 echo "Usage: build.sh [OPTION]..."
30 eceho " -o file Output file (default: $output)"
31 echo " -h This message"
36 while getopts "o:h" opt ; do
47 FULL_VERSION_STRING="$PLC_NAME BootCD $BOOTCD_VERSION"
48 echo "* Building image for $FULL_VERSION_STRING"
50 # Do not tolerate errors
53 # Change to our source directory
54 srcdir=$(cd $(dirname $0) && pwd -P)
55 pushd $srcdir >/dev/null
61 misc=$(mktemp -d /tmp/misc.XXXXXX)
62 trap "rm -rf $misc" ERR INT
64 # initramfs requires that /init be present
65 ln -sf /sbin/init $misc/init
68 echo "$FULL_VERSION_STRING" >$misc/.bootcd
70 # Install GPG, boot, and API server public keys and certificates
71 install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $misc/$PLC_ROOT_GPG_KEY_PUB
72 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $misc/$PLC_BOOT_CA_SSL_CRT
73 install -D -m 644 $PLC_API_CA_SSL_CRT $misc/$PLC_API_CA_SSL_CRT
75 cat > $misc/etc/planetlab/plc_config <<EOF
76 PLC_ROOT_GPG_KEY_PUB='$PLC_ROOT_GPG_KEY_PUB'
78 PLC_BOOT_HOST='$PLC_BOOT_HOST'
79 PLC_BOOT_IP='$PLC_BOOT_IP'
80 PLC_BOOT_PORT=$PLC_BOOT_PORT
81 PLC_BOOT_SSL_PORT=$PLC_BOOT_SSL_PORT
82 PLC_BOOT_CA_SSL_CRT='$PLC_BOOT_CA_SSL_CRT'
84 PLC_API_HOST='$PLC_API_HOST'
85 PLC_API_IP='$PLC_API_IP'
86 PLC_API_PORT=$PLC_API_PORT
87 PLC_API_PATH='$PLC_API_PATH'
88 PLC_API_CA_SSL_CRT='$PLC_API_CA_SSL_CRT'
92 if [ "$PLC_WWW_PORT" = "443" ] ; then
93 PLC_WWW_URL="https://$PLC_WWW_HOST/"
94 elif [ "$PLC_WWW_PORT" != "80" ] ; then
95 PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
97 PLC_WWW_URL="http://$PLC_WWW_HOST/"
101 cat >$misc/etc/issue <<EOF
107 This machine is a node in the $PLC_NAME distributed network. It has
108 not fully booted yet. If you have cancelled the boot process at the
109 request of $PLC_NAME Support, please follow the instructions provided
110 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
112 Console login at this point is restricted to root. Provide the root
113 password of the default $PLC_NAME Central administrator account at the
114 time that this CD was created.
118 # Pack miscellaneous files into a compressed archive
119 echo "* Compressing miscellaneous files image"
120 (cd $misc && find . | cpio --quiet -c -o) | \
121 python ../filesystem/cpiochown.py --owner root:root - | \
122 gzip -9 >$isofs/misc.img
127 # Calculate ramdisk size (total uncompressed size of all initrds)
128 ramdisk_size=$(gzip -l $isofs/*.img | tail -1 | awk '{ print $2; }') # bytes
129 ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
131 # Write isolinux configuration
132 echo "$FULL_VERSION_STRING" >$isofs/version
133 cat >$isofs/isolinux.cfg <<EOF
135 APPEND ramdisk_size=$ramdisk_size initrd=base.img,bootcd.img,misc.img root=/dev/ram0 rw console=tty0
144 echo "* Creating ISO image"
145 mkisofs -o "$output" \
146 -R -allow-leading-dots -J -r \
147 -b isolinux.bin -c boot.cat \
148 -no-emul-boot -boot-load-size 4 -boot-info-table \
151 # XXX Create USB image