3 # Builds bootmanager.sh[.sgn], the PlanetLab Boot Manager script, and
4 # PlanetLab-Bootstrap.tar.bz2, the initial root filesystem of a new
5 # PlanetLab node. For backward compatibility with old version 2.0 Boot
6 # CDs, additional utilities are also built and packaged as
7 # alpina-BootLVM.tar.gz and alpina-PartDisks.tar.gz.
9 # The bootmanager.sh script contains in it a uuencoded tarball of the
10 # Boot Manager, customized for this PLC installation.
12 # Aaron Klingaman <alk@absarokasoft.com>
13 # Mark Huang <mlhuang@cs.princeton.edu>
14 # Copyright (C) 2004-2006 The Trustees of Princeton University
16 # $Id: build.sh,v 1.5 2006/04/03 19:40:55 mlhuang Exp $
19 # Source PLC configuration
20 if [ -f /etc/planetlab/plc_config ] ; then
21 . /etc/planetlab/plc_config
23 PLC_BOOT_HOST=boot.planet-lab.org
24 PLC_API_HOST=www.planet-lab.org
28 # Do not tolerate errors
31 # Change to our source directory
32 srcdir=$(cd $(dirname $0) && pwd -P)
34 # Source bootmanager configuration
35 . $srcdir/source/configuration
37 # Write boot script. plc_www/boot/index.php writes this script out
38 # after a nonce check.
40 DEST_SCRIPT=bootmanager.sh
42 cat > $DEST_SCRIPT <<EOF
45 # PlanetLab Boot Manager $VERSION
47 # DO NOT EDIT. Generated by $USER@$HOSTNAME at
51 # Do not tolerate errors
54 UUDECODE=/usr/bin/uudecode
56 # once we get the beta cds out of use, this can be removed
57 if [ ! -x \$UUDECODE ]; then
58 UUDECODE=/tmp/uudecode
59 curl -s http://$PLC_BOOT_HOST/boot/uudecode.gz | gzip -d -c > \$UUDECODE
65 echo '($UUDECODE | /bin/tar -C /tmp -xj) << _EOF_' >> $DEST_SCRIPT
67 # XXX Currently, the value of PLC_API_PORT is set to 80 by default, so
68 # that the portions of the web site that still use oldapi can continue
69 # to work. However, the Boot Manager supports HTTPS access, which we
70 # want to remain the default, so hard code 443 here.
71 sed -i -e "s@^BOOT_API_SERVER.*@BOOT_API_SERVER=https://$PLC_API_HOST:443/$PLC_API_PATH/@" \
72 $srcdir/source/configuration
74 # Replace the default debug SSH key
75 if [ -f "$PLC_DEBUG_SSH_KEY_PUB" ] ; then
76 install -D -m 644 "$PLC_DEBUG_SSH_KEY_PUB" $srcdir/source/debug_files/debug_root_ssh_key
79 # Embed the uuencoded tarball in the script
80 tar -cj -C $srcdir source/ | uuencode -m - >> $DEST_SCRIPT
82 echo '_EOF_' >> $DEST_SCRIPT
83 echo 'cd /tmp/source' >> $DEST_SCRIPT
84 echo 'chmod +x BootManager.py && ./BootManager.py' >> $DEST_SCRIPT
86 # Sign the whole script, if the keyring is on this machine.
87 if [ -f "$PLC_ROOT_GPG_KEY" -a -f "$PLC_ROOT_GPG_KEY_PUB" ] ; then
89 --no-default-keyring \
90 --keyring "$PLC_ROOT_GPG_KEY_PUB" \
91 --secret-keyring "$PLC_ROOT_GPG_KEY" \
92 --yes --sign --output $DEST_SCRIPT.sgn \
95 echo "Warning: Remember to sign $PWD/$DEST_SCRIPT!" >&2