3 # Builds bootmanager.sh[.sgn], which is the PlanetLab Boot Manager script.
5 # The bootmanager.sh script contains in it a uuencoded tarball of the
6 # Boot Manager, customized for this PLC installation.
8 # Aaron Klingaman <alk@absarokasoft.com>
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Marc E. Fiuczynski <mef@cs.princeton.edu>
11 # Copyright (C) 2004-2007 The Trustees of Princeton University
13 # $Id: build.sh,v 1.5 2006/04/03 19:40:55 mlhuang Exp $
17 # Source PLC configuration
18 . /etc/planetlab/plc_config
20 # Do not tolerate errors
23 # this is set by plc.d/bootmanager
28 # Change to our source directory
31 # Source bootmanager configuration
32 . source/configuration
34 # Write boot script. nodeconfig/boot/index.php retrieves the contents of this script
35 # after checking the node id
37 BMDIR=/var/www/html/boot
40 DEST_SCRIPT="$BMDIR/bootmanager_${DEPLOYMENT}.sh"
41 # Remove the old version or any sym links prior to re-writing
43 rm -f ${DEST_SCRIPT}.sgn
47 sed -i -e "s@^BOOT_API_SERVER.*@BOOT_API_SERVER=https://$PLC_API_HOST:443/$PLC_API_PATH/@" source/configuration
49 sed -i -e "s@^BOOT_SERVER.*@BOOT_SERVER=$PLC_BOOT_HOST@" source/configuration
50 if [ "$PLC_MONITOR_ENABLED" = "1" ]; then
51 MONITOR_SERVER=$PLC_MONITOR_HOST
53 MONITOR_SERVER=$PLC_BOOT_HOST
55 sed -i -e "s@^MONITOR_SERVER.*@MONITOR_SERVER=$MONITOR_SERVER@" source/configuration
57 install -D -m 644 $PLC_BOOT_CA_SSL_CRT source/cacert/$PLC_BOOT_HOST/cacert.pem
58 if [ -f $PLC_MONITOR_CA_SSL_CRT ] ; then
59 install -D -m 644 $PLC_MONITOR_CA_SSL_CRT source/cacert/$PLC_MONITOR_HOST/cacert.pem
62 # Replace the default debug SSH key
63 if [ -f "$PLC_DEBUG_SSH_KEY_PUB" ] ; then
64 install -D -m 644 "$PLC_DEBUG_SSH_KEY_PUB" source/debug_files/debug_root_ssh_key
67 # Add python code from the following packages
68 # make sure they are in the 'Requires' header of the specfile
69 required_rpms="pypcilib pyplnet monitor-runlevelagent"
70 extra_libs=`mktemp -d "/tmp/.bootmanager.XXXXXX"`
71 mkdir $extra_libs/source
72 cp -p $(rpm -ql $required_rpms | grep -v '\.py[co]$') $extra_libs/source
75 ########## create the bootmanager script
76 cat <<EOF > $DEST_SCRIPT
79 # PlanetLab Boot Manager $VERSION
81 # DO NOT EDIT. Generated by $USER@$HOSTNAME at
85 # Do not tolerate errors
88 (/usr/bin/uudecode | /bin/tar -C /tmp -xj) << _EOF_
92 # Embed the uuencoded tarball in the script
93 tar -cj source/ -C $extra_libs source/ | uuencode -m - >> $DEST_SCRIPT
96 echo '_EOF_' >> $DEST_SCRIPT
97 echo 'cd /tmp/source' >> $DEST_SCRIPT
98 echo 'chmod +x BootManager.py && ./BootManager.py' >> $DEST_SCRIPT
100 # Remove temp directory
103 # Sign the whole script, if the keyring is on this machine.
104 if [ -f "$PLC_ROOT_GPG_KEY" -a -f "$PLC_ROOT_GPG_KEY_PUB" ] ; then
105 gpg --homedir=/root \
106 --no-default-keyring \
107 --keyring "$PLC_ROOT_GPG_KEY_PUB" \
108 --secret-keyring "$PLC_ROOT_GPG_KEY" \
109 --yes --sign --output $DEST_SCRIPT.sgn \
112 echo "Warning: Remember to sign $PWD/$DEST_SCRIPT!" >&2